Passed
Push — 5.0 ( 674e23...50290c )
by Luis
38s queued 11s
created

DigraphGenerator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 29
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 9 1
A fromConfiguration() 0 7 1
A __construct() 0 6 1
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.0
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 League\Pipeline\Pipeline;
0 ignored issues
show
Bug introduced by
The type League\Pipeline\Pipeline was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use PhUml\Console\Commands\GeneratorInput;
12
use PhUml\Processors\OutputContent;
13
use PhUml\Stages\CreateDigraph;
14
use PhUml\Stages\FindCode;
15
use PhUml\Stages\ParseCode;
16
use PhUml\Stages\SaveFile;
17
18
/**
19
 * It generates a file with a digraph in DOT format that can be used to create a class diagram
20
 *
21
 * You might want to create a different output using either `neato` or `dot`.
22
 * The file this command creates can be used as an intermediate step.
23
 * For instance:
24
 *
25
 * `neato -Tpdf output.gv > output.pdf`
26
 *
27
 * Where `output.gv` is the file generated by this action
28
 */
29
final class DigraphGenerator
30
{
31 4
    public static function fromConfiguration(DigraphConfiguration $configuration): DigraphGenerator
32
    {
33 4
        return new self(
34 4
            new FindCode($configuration->codeFinder(), $configuration->display()),
35 4
            new ParseCode($configuration->codeParser(), $configuration->display()),
36 4
            new CreateDigraph($configuration->graphvizProcessor(), $configuration->display()),
37 4
            new SaveFile($configuration->writer(), $configuration->display()),
38
        );
39
    }
40
41 4
    private function __construct(
42
        private FindCode $findCode,
43
        private ParseCode $parseCode,
44
        private CreateDigraph $createDigraph,
45
        private SaveFile $saveFile,
46
    ) {
47 4
    }
48
49 3
    public function generate(GeneratorInput $input): void
50
    {
51 3
        $pipeline = (new Pipeline())
52 3
            ->pipe($this->findCode)
53 3
            ->pipe($this->parseCode)
54 3
            ->pipe($this->createDigraph)
55 3
            ->pipe(fn (OutputContent $content) => $this->saveFile->saveTo($content, $input->filePath()));
56
57 3
        $pipeline->process($input->codebaseDirectory());
58 3
    }
59
}
60