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; |
|
|
|
|
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
|
|
|
|