Completed
Push — master ( 797142...deecf0 )
by Luis
06:15 queued 02:52
created

GenerateDotFile::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 8
ccs 7
cts 7
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
namespace PhUml\Actions;
8
9
use PhUml\Parser\CodeFinder;
10
use PhUml\Parser\TokenParser;
11
use PhUml\Processors\GraphvizProcessor;
12
13
class GenerateDotFile extends Action
14
{
15
    /** @var TokenParser */
16
    private $parser;
17
18
    /** @var GraphvizProcessor */
19
    private $dotProcessor;
20
21 15
    public function __construct(TokenParser $parser, GraphvizProcessor $dotProcessor) {
22 15
        $this->parser = $parser;
23 15
        $this->dotProcessor = $dotProcessor;
24 15
    }
25
26
    /**
27
     * @throws \LogicException If the command is missing
28
     */
29 15
    public function generate(CodeFinder $finder, string $dotFilePath): void
30
    {
31 15
        $this->command()->runningParser();
32 12
        $structure = $this->parser->parse($finder);
33 12
        $this->command()->runningProcessor($this->dotProcessor);
34 12
        $dotLanguage = $this->dotProcessor->process($structure);
35 12
        $this->command()->savingResult();
36 12
        $this->dotProcessor->writeToDisk($dotLanguage, $dotFilePath);
37 12
    }
38
}
39