Completed
Push — image-processors-refactoring ( dcd98f )
by Luis
05:57
created

plGraphvizProcessor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 38
ccs 15
cts 18
cp 0.8333
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getInputType() 0 3 1
A name() 0 3 1
A getOutputType() 0 3 1
A process() 0 5 1
1
<?php
2
3
use PhUml\Graphviz\ClassGraphElements;
4
use PhUml\Graphviz\Digraph;
5
use PhUml\Graphviz\HtmlLabelStyle;
6
use PhUml\Graphviz\InterfaceGraphElements;
7
use PhUml\Graphviz\NodeLabelBuilder;
8
use Twig_Environment as TemplateEngine;
9
use Twig_Loader_Filesystem as Filesystem;
10
11
class plGraphvizProcessor extends plProcessor
12
{
13
    public $options;
14
15
    /** @var Digraph */
16
    private $digraph;
17
18 6
    public function __construct(Digraph $digraph = null)
19
    {
20 6
        $this->options = new plGraphvizProcessorOptions();
21 6
        $labelBuilder = new NodeLabelBuilder(new TemplateEngine(
22 6
            new FileSystem(__DIR__ . '/../../Graphviz/templates')
23 6
        ), new HtmlLabelStyle());
24 6
        $classElements = new ClassGraphElements($this->options->createAssociations, $labelBuilder);
0 ignored issues
show
Bug Best Practice introduced by
The property createAssociations does not exist on plGraphvizProcessorOptions. Since you implemented __get, consider adding a @property annotation.
Loading history...
25 6
        $interfaceElements = new InterfaceGraphElements($labelBuilder);
26 6
        $this->digraph = $digraph ?? new Digraph($interfaceElements, $classElements);
27 6
    }
28
29 3
    public function name(): string
30
    {
31 3
        return 'Graphviz';
32
    }
33
34 9
    public function getInputType(): string
35
    {
36 9
        return 'application/phuml-structure';
37
    }
38
39 3
    public function getOutputType(): string
40
    {
41 3
        return 'text/dot';
42
    }
43
44
    public function process($input)
45
    {
46
        $this->digraph->fromCodeStructure($input);
47
48
        return $this->digraph->toDotLanguage();
49
    }
50
}
51