Passed
Push — master ( 1416ae...b5a8b1 )
by Luis
54s queued 13s
created

ClassDiagramConfiguration::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 2
dl 0
loc 11
ccs 10
cts 10
cp 1
crap 2
rs 9.9666
c 0
b 0
f 0
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\Generators;
9
10
use PhUml\Parser\CodeFinder;
11
use PhUml\Parser\CodeFinderConfiguration;
12
use PhUml\Parser\CodeParser;
13
use PhUml\Parser\CodeParserConfiguration;
14
use PhUml\Parser\SourceCodeFinder;
15
use PhUml\Processors\GraphvizConfiguration;
16
use PhUml\Processors\GraphvizProcessor;
17
use PhUml\Processors\ImageProcessor;
18
use PhUml\Processors\ImageProcessorName;
19
use PhUml\Processors\OutputWriter;
20
use PhUml\Stages\ProgressDisplay;
21
use Symplify\SmartFileSystem\SmartFileSystem;
22
23
final class ClassDiagramConfiguration
24
{
25
    private readonly CodeFinder $codeFinder;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 25 at column 21
Loading history...
26
27
    private readonly CodeParser $codeParser;
28
29
    private readonly GraphvizProcessor $graphvizProcessor;
30
31
    private readonly ImageProcessor $imageProcessor;
32
33
    private readonly OutputWriter $writer;
34
35
    /**
36
     * @param array{
37
     *     processor: string,
38
     *     recursive: bool,
39
     *     associations: bool,
40
     *     "hide-private": bool,
41
     *     "hide-protected": bool,
42
     *     "hide-methods": bool,
43
     *     "hide-attributes": bool,
44
     *     "hide-empty-blocks": bool,
45
     *     theme: string
46
     *  } $options
47
     */
48 8
    public function __construct(array $options, private readonly ProgressDisplay $display)
49
    {
50 8
        $this->codeFinder = SourceCodeFinder::fromConfiguration(new CodeFinderConfiguration($options));
51 8
        $this->codeParser = CodeParser::fromConfiguration(new CodeParserConfiguration($options));
52 8
        $this->graphvizProcessor = GraphvizProcessor::fromConfiguration(new GraphvizConfiguration($options));
53 8
        $imageProcessorName = new ImageProcessorName($options['processor']);
54 7
        $filesystem = new SmartFileSystem();
55 7
        $this->imageProcessor = $imageProcessorName->isDot()
56 1
            ? ImageProcessor::dot($filesystem)
57 6
            : ImageProcessor::neato($filesystem);
58 7
        $this->writer = new OutputWriter($filesystem);
59
    }
60
61 7
    public function codeFinder(): CodeFinder
62
    {
63 7
        return $this->codeFinder;
64
    }
65
66 7
    public function codeParser(): CodeParser
67
    {
68 7
        return $this->codeParser;
69
    }
70
71 7
    public function graphvizProcessor(): GraphvizProcessor
72
    {
73 7
        return $this->graphvizProcessor;
74
    }
75
76 7
    public function imageProcessor(): ImageProcessor
77
    {
78 7
        return $this->imageProcessor;
79
    }
80
81 7
    public function writer(): OutputWriter
82
    {
83 7
        return $this->writer;
84
    }
85
86 7
    public function display(): ProgressDisplay
87
    {
88 7
        return $this->display;
89
    }
90
}
91