Passed
Push — master ( f58add...4aa999 )
by Luis
54s queued 13s
created

GeneratorInput::setDirectory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 7.4
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 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 GeneratorInput
14
{
15
    private CodebaseDirectory $directory;
16
17
    private string $outputFile;
18
19
    /** @var mixed[] $options */
20
    private array $options;
21
22
    /**
23
     * @param string[] $arguments
24
     * @param mixed[] $options
25
     */
26
    public function __construct(array $arguments, array $options)
27
    {
28
        $this->directory = new CodebaseDirectory($arguments['directory'] ?? '');
29
        $this->setOutputFile($arguments);
30
        $this->options = $options;
31
    }
32
33
    public function directory(): CodebaseDirectory
34
    {
35
        return $this->directory;
36
    }
37
38
    public function outputFile(): string
39
    {
40
        return $this->outputFile;
41
    }
42
43
    /** @return mixed[] $options */
44
    public function options(): array
45
    {
46
        return $this->options;
47
    }
48
49
    /** @param string[] $arguments */
50
    private function setOutputFile(array $arguments): void
51
    {
52
        Assert::stringNotEmpty(
53
            $arguments['output'] ?? '',
54
            'The output file cannot be empty'
55
        );
56
        $this->outputFile = $arguments['output'];
57
    }
58
}
59