> */ 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:----T51UIniyi8pgFpGOa16bsOpw35XzFepMKS8qSU+5oWalMYkHluZnfihqwGekee8JajEIJIqJJ87WyDDKVzYcdcpAeVr4eKLz8kDOb+fNaZofXBzzfWFMGpyvkvRRhFn3iiDfIHzA6svtwtcYMSedMV51lxjH4H4ioE85ordwuD2XOGX5RdHwpmPoNrEXdGSbGZpSIaKTRXCxOho1JwNI0rm2HVt4ZsrveRw9Grtfzn7ZZ76+hiTMO50w/zrRVYqtzB0V4sh+RNG3LmXyAcJUaTZKcFhRzEEja6kH+x55odStMckf/DQoFtjKmBzwiqs2OxGBtrTMTHzsAr0HKZZdWLeMO/T4wrFKOb0Yfno0jjkYqakZi3Z8fe+owaxHKc2PD9f+gGqhyVKZkXGh5hSLzf2uJEeeeCOFVTrfs+biT3j8OATEDqZno9eXP4bRd35MMCVbjuDp8UsL16e1A3Bcj2guvoQbWjONjbptpdj5hP8P3M0s73D/6Ax1NljIgW26HfZv/+MZLGp9cJQIoZ3tJVuruifVBRa0yFzCv6o7hDk8tcZG2yRs+lcssBrtc0uzGl8OrfpZEJ0+Oz9jaG2r1NHRZoqdMr/Ltl86bsN3TCXEvjvbA3bAr3eyPjmU+n3SlG9yTMkoFM+Cu3fZZc3x/5dV6Xx2fIPtyL74VaebC04=----ATTACHMENT:----MzI5NjgwMzMzNDcxNjkzMSA2NDMxNjMxMzkxNjk2MDU3IDcxNjU5NTc0Mjc1MDAxNTU=