Passed
Pull Request — master (#22)
by Luis
24:40 queued 21:48
created

GeneratorInput   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 39
ccs 14
cts 14
cp 1
rs 10
c 1
b 0
f 0
wmc 6
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.1
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\Console\Commands;
9
10
use PhUml\Parser\CodebaseDirectory;
11
use PhUml\Processors\OutputFilePath;
12
13
final class GeneratorInput
14
{
15
    private readonly CodebaseDirectory $directory;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 15 at column 21
Loading history...
16
17
    private readonly OutputFilePath $outputFile;
18
19
    /** @param string[] $input */
20 4
    public static function dotFile(array $input): GeneratorInput
21
    {
22 4
        return new GeneratorInput($input, 'gv');
23
    }
24
25
    /** @param string[] $input */
26 4
    public static function textFile(array $input): GeneratorInput
27
    {
28 4
        return new GeneratorInput($input, 'txt');
29
    }
30
31
    /** @param string[] $input */
32 7
    public static function pngFile(array $input): GeneratorInput
33
    {
34 7
        return new GeneratorInput($input, 'png');
35
    }
36
37
    /** @param string[] $input */
38 15
    private function __construct(array $input, string $extension)
39
    {
40 15
        $this->directory = new CodebaseDirectory($input['directory'] ?? '');
41 12
        $this->outputFile = OutputFilePath::withExpectedExtension($input['output'] ?? '', $extension);
42
    }
43
44 12
    public function filePath(): OutputFilePath
45
    {
46 12
        return $this->outputFile;
47
    }
48
49 12
    public function codebaseDirectory(): CodebaseDirectory
50
    {
51 12
        return $this->directory;
52
    }
53
}
54