Completed
Push — master ( 389baa...c7c5a4 )
by Luis
14:17 queued 08:06
created

DigraphPrinter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toDot() 0 5 1
1
<?php
2
/**
3
 * PHP version 7.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\Graphviz;
9
10
use PhUml\Graphviz\Styles\DefaultDigraphStyle;
11
use PhUml\Graphviz\Styles\DigraphStyle;
12
use PhUml\Templates\TemplateEngine;
13
14
class DigraphPrinter
15
{
16
    /** @var TemplateEngine */
17
    private $engine;
18
19
    /** @var DigraphStyle */
20
    private $style;
21
22 108
    public function __construct(TemplateEngine $engine = null, DigraphStyle $style = null)
23
    {
24 108
        $this->engine = $engine ?? new TemplateEngine();
25 108
        $this->style = $style ?? new DefaultDigraphStyle();
26 108
    }
27
28 93
    public function toDot(Digraph $digraph): string
29
    {
30 93
        return trim($this->engine->render('digraph.html.twig', [
31 93
            'digraph' => $digraph,
32 93
            'style' => $this->style,
33
        ]));
34
    }
35
}
36