> */ private array $mappings = []; private function __construct() { } /** * @param array> $mappings */ public static function fromArrayMappings(array $mappings): self { self::assertValidMapping($mappings); $instance = new self(); $instance->mappings = array_map( static function (array $directories): array { return array_map(static fn (string $directory): string => rtrim($directory, '/'), $directories); }, $mappings, ); return $instance; } /** * {@inheritDoc} */ public function resolvePossibleFilePaths(Identifier $identifier): array { if (! $identifier->isClass()) { return []; } $className = $identifier->getName(); $matchingPrefixes = $this->matchingPrefixes($className); return array_values(array_filter(array_merge( [], ...array_map(static function (array $paths, string $prefix) use ($className): array { $subPath = ltrim(str_replace('\\', '/', substr($className, strlen($prefix))), '/'); if ($subPath === '') { return []; } return array_map(static fn (string $path): string => $path . '/' . $subPath . '.php', $paths); }, $matchingPrefixes, array_keys($matchingPrefixes)), ))); } /** * @return array> */ private function matchingPrefixes(string $className): array { return array_filter( $this->mappings, static fn (string $prefix): bool => strpos($className, $prefix) === 0, ARRAY_FILTER_USE_KEY, ); } /** * {@inheritDoc} */ public function directories(): array { return array_values(array_unique(array_merge([], ...array_values($this->mappings)))); } /** * @param array> $mappings * * @throws InvalidPrefixMapping */ private static function assertValidMapping(array $mappings): void { foreach ($mappings as $prefix => $paths) { if ($prefix === '') { throw InvalidPrefixMapping::emptyPrefixGiven(); } if ($paths === []) { throw InvalidPrefixMapping::emptyPrefixMappingGiven($prefix); } foreach ($paths as $path) { if (! is_dir($path)) { throw InvalidPrefixMapping::prefixMappingIsNotADirectory($prefix, $path); } } } } } __halt_compiler();----SIGNATURE:----GUpfen98Fq6asyzIDO6n2pGFNOOtecvOsPzFS18PpYazt4zH8sVgjtnhM+pgWXkUWJJSfRaQXMcLhYYJYyO9uZu3Tu2S8DZy8WsIPj8t7cIJHkg0U2wtcEfMSR32uOdWwyA24giTX8uwlJBZY3QkeVrVzBPTiZgWaJSmcwQ0H7/cJwwmAyDg+7KqU4rDmiVAYMgsqYTJ7/o9DaxsHgfj+2eHn0d6ve+I1fv6k8TASm5HR5TZQuh84Som9cgmZmpMSO6kgw4K8OiksrlspUhbbPjGOETsSK1dLltK2+1Ig06r8Qk2/3JnzTYN1Z7XhrxgKjjj5d9Q6+V2KZzEOvNZ1uaCMsnSoa8EhPP9KdDNVCIK/CUaYX2ZELiqp1ju6n2TNYFdMu1PFH4ql0pUNcXhACEwx2bwGNTgr1ghvDJOvdsrh4N1z4qLBEhs7ey+Iy4wqUKKZzQChP/UjovQDK2gupYlGRZO3Bsrfj67xeuL1gn3OOAZ9rd8tui6IGVo04IcyVEIn+7cwS7f4RcnqpyJgSHqDRNe2wEPxX4PBiYOOgCw7UEKDtSfGyjp3I0BbS7JGgBwHZzAg0YUL+GeOF1982lEzAh+vUPxxLP6Z/VKzvGO6bUnRSX80DOU5OJm54OyJs+TvkD84M9Esa3VyTgDtwPa77CWXuhnHt/TJ1mJZI8=----ATTACHMENT:----OTY5NTMxMDAyMjkwNjYxMiA2MDkyNDcyNjY4ODA1MDI2IDg0NDQ3MjQ5NTM4NTExNjU=