*/ private $destinations = []; /** * @param array $destinations */ private function __construct(string $basePath, array $destinations) { $this->basePath = $basePath; $this->destinations = $destinations; } /** * @param array $destinations */ public static function fromDestinations(array $destinations): PathFinder { return new self('', array_map(function (string $pattern) { return Pattern::fromPattern($pattern); }, $destinations)); } /** * @param array $destinations */ public static function fromAbsoluteDestinations(string $basePath, array $destinations): PathFinder { return new self($basePath, array_map(function (string $pattern) { return Pattern::fromPattern($pattern); }, $destinations)); } /** * Return a hash map of destination names to paths representing * paths which relate to the given file path. * * @throws NoMatchingSourceException * @return array */ public function destinationsFor(string $filePath): array { if ($this->basePath !== '') { $filePath = Path::makeRelative($filePath, $this->basePath); } $destinations = []; $sourcePattern = $this->findSourcePattern($filePath); foreach ($this->destinations as $name => $pattern) { assert($pattern instanceof Pattern); if ($pattern === $sourcePattern) { continue; } $tokens = $sourcePattern->tokens($filePath); $destinations[$name] = $pattern->replaceTokens($tokens); } return $destinations; } private function findSourcePattern(string $filePath): Pattern { foreach ($this->destinations as $name => $pattern) { assert($pattern instanceof Pattern); if ($pattern->fits($filePath)) { return $pattern; } } throw new NoMatchingSourceException(sprintf( 'Could not find matching source pattern for "%s", known patterns: "%s"', $filePath, implode('", "', array_map(function (Pattern $pattern) { return $pattern->toString(); }, $this->destinations)) )); } } __halt_compiler();----SIGNATURE:----Rx2CoSishs+jnWp+ZneaO+RNDfx2gH9BAkMTKJrcIQAEO9Sc9L1B8cm26A7m5wV4KnP6K3DNcRWafTjay+DaSM5+Za+lOBBVSzTvAztPdGyomzY4T8FjFfZ0penLLBW6vxWcV7wdtfuEz1+VJcvrL9ABT/GkdkeK278OaCaoq9N4KrFK7W8HgXFp0ljldhwTj6o5DQzgdEEGgtkoJFgJqEOd3d8gCVe94LXTMnercaym6Er6dVEtUp21hznLw04lYheNMjrzrFsVo0E3PQOeG5a7YUVWWpJXCCBhMT00R83uQThv2iCZ4ByGqszB8QU8vvaD1kJziWKmEvMuz81g87L8kfUVRemDrfVYibEKe2gii5TPaRt4P7wWtjqf2uXwaEWWvnxC8O5/qG4HusASzNuU9x/4LBsWEc7+RWxBE3JP6J4aJXSNo3sFRR6i958u98k0Mys9YxAe69hqdigeFjrzulQFKYO4YlXnqKlujKs8njxk05id3XgHMvTmmQp1U5BEA1PQKrMQLWldpFzHPZWgsx2nOT9xFW7dOFmoGNxHk7JB7+swa+hjoIQGEScEtafw8c7BGlQtOCCV174DdDwUjXcMKxXAxp8M+83qacZ4pRqlmLD09GJcWXch0Hgq2PYvoTOQUo0VnmlCSxhpXWgjCrqP315SI4Yh9qvULeM=----ATTACHMENT:----NTU4NDIzNTkxNzc1NzM1NCA1MTY4OTUyMzgyMzQ2ODYxIDcwMDQ1NTExNzMwMzgzNg==