> */ 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:----p+Y7KnWvEodNcwcD3/BR5TXIPQJlBAMorfBGu4MvrmsUK1gbr5H1p2zRkENTgZfOxXSLklqu4A8i+n5Yl47if404Z4z18Pr8TmPJM3/c64YZiNbd3qzcShaD3FDBjG0qpn5VTfhc2RuB75D9zRwKuvvAAM2YUAwe1KNCOyKopHDDTuAhNbEPLsHkv91ThMQmddFMd212rjHxPbJkFUb+JfdHF8wmmrW5/btBkjRv0DtwkVwabMfDxMclYK9xMpnK3nj7PztBwaP/QY7xhUeF4IVAu3p/Ro6FuWkPJf2v8sgx7rSDxASQYmWjgTcssSpeO7YPU5UfHWf4+vDv2KaVuNNDcxFRj2Dc3vBNbBLDW1GE7z6HL7pcht7bF/ATwTr2hU5cw3y56uhXM4FQCeZZhOBVuEZmkeNBN8AnqG3Xj5Zf3BssMh9paVtT5XSFAmjDWwD8HT0mu8nxJqItn4+DFLdPY4xunuDvGQaKa3Lau/I13FmxaJJGywD5mpYAXjn78+cJtMlBxwCrsFI6maYwsY9F+F3EULa4CnhoN52o8CzJv48Hy9vXSJQ/sc9I4Bh7zR5f9kZU3gL6TBlIW80+vPcmK2uW1i1pFHKR6H/O9EUgIEdrQak9BwZ8ibKWPq778xFh8SCKZnNucuiPvakfsow0JHrhfgLtawbxJW6x5oA=----ATTACHMENT:----NTg1Nzk4MDgyNDY3MjEyOCA1MzM2NTU0ODkzNDU4OTIgNjMyMjM4NzMyOTc0NjYwNQ==