first commit.

This commit is contained in:
kj
2026-10-05 15:08:39 -03:00
commit b7799f9fff
93 changed files with 8966 additions and 0 deletions
@@ -0,0 +1,43 @@
<?php
namespace Toolbox;
/**
* Regla de destino: `src/**` -> ROOT_CORE (sin el prefijo `src/`); el resto ->
* ROOT_DIR. Admite un mapa explícito por componente.
*/
final class Destination
{
public static function resolve(
string $source,
string $rootDir,
string $rootCore,
?array $explicit = null
): string {
$target = self::relative($source, $rootDir, $rootCore, $explicit);
return rtrim($rootDir, '/') . '/' . $target;
}
public static function relative(
string $source,
string $rootDir,
string $rootCore,
?array $explicit = null
): string {
if ($explicit !== null && isset($explicit[$source])) {
return ltrim($explicit[$source], '/');
}
$source = ltrim($source, '/');
if (str_starts_with($source, 'src/')) {
$inCore = substr($source, 4);
$prefix = rtrim(str_replace(rtrim($rootDir, '/') . '/', '', $rootCore), '/');
return ($prefix === '' ? '' : $prefix . '/') . $inCore;
}
return $source;
}
}