Passed
Push — 5.0 ( d46d5f )
by Luis
39s queued 12s
created

GraphvizConfiguration::associationsBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.0
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