Passed
Push — union-types ( b56600...45a674 )
by Luis
13:38
created

OutputFilePath::value()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.0
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Processors;
9
10
use SplFileInfo;
11
use Webmozart\Assert\Assert;
0 ignored issues
show
Bug introduced by
The type Webmozart\Assert\Assert was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
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
        Assert::eq(
20
            $extension,
21
            $expectedExtension,
22
            "Output file is expected to have extension '.{$expectedExtension}', '.{$extension}' given"
23
        );
24
25
        return new OutputFilePath($path);
26
    }
27
28
    private function __construct(private SplFileInfo $filePath)
29
    {
30
    }
31
32
    public function value(): string
33
    {
34
        return $this->filePath->getPathname();
35
    }
36
}
37