Passed
Pull Request — master (#22)
by Luis
24:40 queued 21:48
created

GraphvizConfiguration   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 28
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 5
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\Processors;
9
10
use PhUml\Graphviz\Builders\AssociationsBuilder;
11
use PhUml\Graphviz\Builders\EdgesBuilder;
12
use PhUml\Graphviz\Builders\NoAssociationsBuilder;
13
use PhUml\Graphviz\Styles\DigraphStyle;
14
use PhUml\Graphviz\Styles\ThemeName;
15
use Webmozart\Assert\Assert;
16
17
final class GraphvizConfiguration
18
{
19
    private readonly AssociationsBuilder $associationsBuilder;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 19 at column 21
Loading history...
20
21
    private readonly DigraphStyle $digraphStyle;
22
23
    /** @param mixed[] $options */
24 22
    public function __construct(array $options)
25
    {
26 22
        Assert::boolean($options['associations'], 'Generate digraph associations option must be a boolean value');
27 21
        $this->associationsBuilder = $options['associations'] ? new EdgesBuilder() : new NoAssociationsBuilder();
28 21
        Assert::string($options['theme'], 'Theme option must be a string value');
29 20
        $theme = new ThemeName($options['theme']);
30 19
        Assert::boolean($options['hide-empty-blocks'], 'Hide digraph empty blocks option must be a boolean value');
31 18
        $hideEmptyBlocks = $options['hide-empty-blocks'];
32 18
        $this->digraphStyle = $hideEmptyBlocks
33 3
            ? DigraphStyle::withoutEmptyBlocks($theme)
34 15
            : DigraphStyle::default($theme);
35
    }
36
37 18
    public function associationsBuilder(): AssociationsBuilder
38
    {
39 18
        return $this->associationsBuilder;
40
    }
41
42 18
    public function digraphStyle(): DigraphStyle
43
    {
44 18
        return $this->digraphStyle;
45
    }
46
}
47