Passed
Push — union-types ( b56600 )
by Luis
14:03
created

StatisticsGeneratorConfiguration   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A writer() 0 3 1
A statisticsProcessor() 0 3 1
A codeFinder() 0 3 1
A codeParser() 0 3 1
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\Generators;
9
10
use PhUml\Parser\CodeFinder;
11
use PhUml\Parser\CodeParser;
12
use PhUml\Parser\CodeParserConfiguration;
13
use PhUml\Parser\SourceCodeFinder;
14
use PhUml\Processors\OutputWriter;
15
use PhUml\Processors\StatisticsProcessor;
16
use PhUml\Templates\TemplateEngine;
17
use Symplify\SmartFileSystem\SmartFileSystem;
0 ignored issues
show
Bug introduced by
The type Symplify\SmartFileSystem\SmartFileSystem 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...
18
19
final class StatisticsGeneratorConfiguration
20
{
21
    private CodeFinder $codeFinder;
22
23
    private CodeParser $codeParser;
24
25
    private StatisticsProcessor $statisticsProcessor;
26
27
    private OutputWriter $writer;
28
29
    /** @param mixed[] $configuration */
30
    public function __construct(array $configuration)
31
    {
32
        $recursive = (bool) ($configuration['recursive'] ?? false);
33
        $this->codeFinder = $recursive ? SourceCodeFinder::recursive() : SourceCodeFinder::nonRecursive();
34
        $this->codeParser = CodeParser::fromConfiguration(new CodeParserConfiguration($configuration));
35
        $this->statisticsProcessor = new StatisticsProcessor(new TemplateEngine());
36
        $this->writer = new OutputWriter(new SmartFileSystem());
37
    }
38
39
    public function codeParser(): CodeParser
40
    {
41
        return $this->codeParser;
42
    }
43
44
    public function codeFinder(): CodeFinder
45
    {
46
        return $this->codeFinder;
47
    }
48
49
    public function statisticsProcessor(): StatisticsProcessor
50
    {
51
        return $this->statisticsProcessor;
52
    }
53
54
    public function writer(): OutputWriter
55
    {
56
        return $this->writer;
57
    }
58
}
59