| Total Complexity | 5 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class FileMapper implements FileMatcher |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $originalPath; |
||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | protected $newPath; |
||
| 21 | |||
| 22 | public function __construct(string $originalPath, string $newPath) |
||
| 23 | { |
||
| 24 | $this->originalPath = $originalPath; |
||
| 25 | $this->newPath = $newPath; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * {@inheritdoc} |
||
| 30 | */ |
||
| 31 | public function match(string $needle, array $haystack): string |
||
| 32 | { |
||
| 33 | foreach ($haystack as $file) { |
||
| 34 | if ($this->checkMapping($file, $needle)) { |
||
| 35 | return $file; |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | throw new FileNotFound(); |
||
| 40 | } |
||
| 41 | |||
| 42 | private function checkMapping(string $file, string $needle): bool |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |