| Total Complexity | 3 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 13 | final class OutputFilePath |
||
| 14 | { |
||
| 15 | public static function withExpectedExtension(string $filePath, string $expectedExtension): OutputFilePath |
||
| 16 | { |
||
| 17 | $path = new SplFileInfo(trim($filePath)); |
||
| 18 | $extension = $path->getExtension(); |
||
| 19 | $directory = realpath($path->getPath()); |
||
| 20 | Assert::true($directory !== false, "Directory '{$path->getPath()}' does not exist"); |
||
| 21 | Assert::eq( |
||
| 22 | $extension, |
||
| 23 | $expectedExtension, |
||
| 24 | "Output file is expected to have extension '.{$expectedExtension}', '.{$extension}' given" |
||
| 25 | ); |
||
| 26 | |||
| 27 | return new OutputFilePath(new SplFileInfo($directory . '/' . $path->getBasename())); |
||
| 28 | } |
||
| 29 | |||
| 30 | private function __construct(private readonly SplFileInfo $filePath) |
||
|
|
|||
| 31 | { |
||
| 32 | } |
||
| 33 | |||
| 34 | public function value(): string |
||
| 35 | { |
||
| 36 | return $this->filePath->getPathname(); |
||
| 37 | } |
||
| 39 |