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

GraphvizConfiguration   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 26
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A associationsBuilder() 0 3 1
A __construct() 0 9 3
A digraphStyle() 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\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
16
final class GraphvizConfiguration
17
{
18
    private AssociationsBuilder $associationsBuilder;
19
20
    private DigraphStyle $digraphStyle;
21
22
    /** @param mixed[] $configuration */
23
    public function __construct(array $configuration)
24
    {
25
        $extractAssociations = (bool) ($configuration['associations'] ?? false);
26
        $this->associationsBuilder = $extractAssociations ? new EdgesBuilder() : new NoAssociationsBuilder();
27
        $theme = new ThemeName($configuration['theme']);
28
        $hideEmptyBlocks = (bool) ($configuration['hide-empty-blocks'] ?? false);
29
        $this->digraphStyle = $hideEmptyBlocks
30
            ? DigraphStyle::withoutEmptyBlocks($theme)
31
            : DigraphStyle::default($theme);
32
    }
33
34
    public function associationsBuilder(): AssociationsBuilder
35
    {
36
        return $this->associationsBuilder;
37
    }
38
39
    public function digraphStyle(): DigraphStyle
40
    {
41
        return $this->digraphStyle;
42
    }
43
}
44