Passed
Push — dependabot/npm_and_yarn/npm-8.... ( a37e8a )
by
unknown
10:51
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 13
cts 13
cp 1
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A dotFile() 0 3 1
A codebaseDirectory() 0 3 1
A textFile() 0 3 1
A filePath() 0 3 1
A pngFile() 0 3 1
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