Passed
Push — dependabot/npm_and_yarn/npm-8.... ( a37e8a )
by
unknown
10:51
created

GeneratorInput::codebaseDirectory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
4
 */
5
6
namespace PhUml\Console\Commands;
7
8
use PhUml\Parser\CodebaseDirectory;
9
use PhUml\Processors\OutputFilePath;
10
11
final class GeneratorInput
12
{
13
    private readonly CodebaseDirectory $directory;
14
15
    private readonly OutputFilePath $outputFile;
16
17
    /** @param string[] $input */
18 4
    public static function dotFile(array $input): GeneratorInput
19
    {
20 4
        return new GeneratorInput($input, 'gv');
21
    }
22
23
    /** @param string[] $input */
24 4
    public static function textFile(array $input): GeneratorInput
25
    {
26 4
        return new GeneratorInput($input, 'txt');
27
    }
28
29
    /** @param string[] $input */
30 7
    public static function pngFile(array $input): GeneratorInput
31
    {
32 7
        return new GeneratorInput($input, 'png');
33
    }
34
35
    /** @param string[] $input */
36 15
    private function __construct(array $input, string $extension)
37
    {
38 15
        $this->directory = new CodebaseDirectory($input['directory'] ?? '');
0 ignored issues
show
Bug introduced by
The property directory is declared read-only in PhUml\Console\Commands\GeneratorInput.
Loading history...
39 12
        $this->outputFile = OutputFilePath::withExpectedExtension($input['output'] ?? '', $extension);
0 ignored issues
show
Bug introduced by
The property outputFile is declared read-only in PhUml\Console\Commands\GeneratorInput.
Loading history...
40
    }
41
42 12
    public function filePath(): OutputFilePath
43
    {
44 12
        return $this->outputFile;
45
    }
46
47 12
    public function codebaseDirectory(): CodebaseDirectory
48
    {
49 12
        return $this->directory;
50
    }
51
}
52