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

GeneratorInput   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 39
rs 10
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
 * 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\Console\Commands;
9
10
use PhUml\Parser\CodebaseDirectory;
11
use PhUml\Processors\OutputFilePath;
12
13
final class GeneratorInput
14
{
15
    private CodebaseDirectory $directory;
16
17
    private OutputFilePath $outputFile;
18
19
    /** @param string[] $input */
20
    public static function dotFile(array $input): GeneratorInput
21
    {
22
        return new GeneratorInput($input, 'gv');
23
    }
24
25
    /** @param string[] $input */
26
    public static function textFile(array $input): GeneratorInput
27
    {
28
        return new GeneratorInput($input, 'txt');
29
    }
30
31
    /** @param string[] $input */
32
    public static function pngFile(array $input): GeneratorInput
33
    {
34
        return new GeneratorInput($input, 'png');
35
    }
36
37
    /** @param string[] $input */
38
    private function __construct(array $input, string $extension)
39
    {
40
        $this->directory = new CodebaseDirectory($input['directory'] ?? '');
41
        $this->outputFile = OutputFilePath::withExpectedExtension($input['output'] ?? '', $extension);
42
    }
43
44
    public function filePath(): OutputFilePath
45
    {
46
        return $this->outputFile;
47
    }
48
49
    public function codebaseDirectory(): CodebaseDirectory
50
    {
51
        return $this->directory;
52
    }
53
}
54