Passed
Push — 1.1 ( 13f027 )
by Luis
06:39
created

DotFileGenerator::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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\Generators;
9
10
use PhUml\Parser\CodeFinder;
11
12
/**
13
 * It generates a file with a digraph in DOT format that can be used to create a class diagram
14
 *
15
 * You might want to create a different output using either `neato` or `dot`.
16
 * The file this command creates can be used as an intermediate step.
17
 * For instance:
18
 *
19
 * `neato -Tpdf output.gv > output.pdf`
20
 *
21
 * Where `output.gv` is the file generated by this action
22
 */
23
class DotFileGenerator extends DigraphGenerator
24
{
25
    /**
26
     * The process to generate a class diagram is as follows
27
     *
28
     * 1. The parser produces a collection of classes and interfaces
29
     * 2. The `graphviz` processor takes this collection and creates a digraph using the DOT language
30
     * 4. The DOT file is saved to the given path
31
     *
32
     * @throws \LogicException If the command is missing
33
     */
34 18
    public function generate(CodeFinder $finder, string $dotFilePath): void
35
    {
36 18
        $this->display()->start();
37
38 15
        $digraph = $this->generateDigraph($this->parseCode($finder));
39
40 15
        $this->save($this->digraphProcessor, $digraph, $dotFilePath);
41 15
    }
42
}
43