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

plGraphvizProcessor::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 9.4285
c 1
b 0
f 0
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