|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/** |
|
3
|
|
|
* PHP version 7.4 |
|
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; |
|
|
|
|
|
|
11
|
|
|
use PhUml\Console\Commands\GeneratorInput; |
|
12
|
|
|
use PhUml\Parser\CodeFinder; |
|
13
|
|
|
use PhUml\Parser\CodeParser; |
|
14
|
|
|
use PhUml\Processors\GraphvizProcessor; |
|
15
|
|
|
use PhUml\Processors\ImageProcessor; |
|
16
|
|
|
use PhUml\Processors\OutputWriter; |
|
17
|
|
|
use PhUml\Stages\CreateClassDiagram; |
|
18
|
|
|
use PhUml\Stages\CreateDigraph; |
|
19
|
|
|
use PhUml\Stages\FindCode; |
|
20
|
|
|
use PhUml\Stages\ParseCode; |
|
21
|
|
|
use PhUml\Stages\SaveFile; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* It generates a UML class diagram from a directory with PHP code |
|
25
|
|
|
* |
|
26
|
|
|
* The image produced is a `.png` that will be saved in a specified path |
|
27
|
|
|
*/ |
|
28
|
|
|
final class ClassDiagramGenerator |
|
29
|
|
|
{ |
|
30
|
|
|
private CodeFinder $codeFinder; |
|
31
|
|
|
|
|
32
|
|
|
private CodeParser $codeParser; |
|
33
|
|
|
|
|
34
|
|
|
private GraphvizProcessor $graphvizProcessor; |
|
35
|
|
|
|
|
36
|
|
|
private ImageProcessor $imageProcessor; |
|
37
|
|
|
|
|
38
|
|
|
private OutputWriter $writer; |
|
39
|
|
|
|
|
40
|
|
|
public static function fromConfiguration(ClassDiagramConfiguration $configuration): ClassDiagramGenerator |
|
41
|
|
|
{ |
|
42
|
|
|
return new self( |
|
43
|
|
|
$configuration->codeFinder(), |
|
44
|
|
|
$configuration->codeParser(), |
|
45
|
|
|
$configuration->graphvizProcessor(), |
|
46
|
|
|
$configuration->imageProcessor(), |
|
47
|
|
|
$configuration->writer() |
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function __construct( |
|
52
|
|
|
CodeFinder $codeFinder, |
|
53
|
|
|
CodeParser $codeParser, |
|
54
|
|
|
GraphvizProcessor $graphvizProcessor, |
|
55
|
|
|
ImageProcessor $imageProcessor, |
|
56
|
|
|
OutputWriter $writer |
|
57
|
|
|
) { |
|
58
|
|
|
$this->codeFinder = $codeFinder; |
|
59
|
|
|
$this->codeParser = $codeParser; |
|
60
|
|
|
$this->graphvizProcessor = $graphvizProcessor; |
|
61
|
|
|
$this->imageProcessor = $imageProcessor; |
|
62
|
|
|
$this->writer = $writer; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* The process to generate a class diagram is as follows |
|
67
|
|
|
* |
|
68
|
|
|
* 1. The parser produces a collection of classes, interfaces and traits |
|
69
|
|
|
* 2. The `graphviz` processor takes this collection and creates a digraph using the DOT language |
|
70
|
|
|
* 3. Either the `neato` or `dot` processor will produce a `.png` class diagram from the digraph |
|
71
|
|
|
* 4. The image is saved to the given path |
|
72
|
|
|
*/ |
|
73
|
|
|
public function generate(GeneratorInput $input): void |
|
74
|
|
|
{ |
|
75
|
|
|
$pipeline = (new Pipeline()) |
|
76
|
|
|
->pipe(new FindCode($this->codeFinder, $input->display())) |
|
77
|
|
|
->pipe(new ParseCode($this->codeParser, $input->display())) |
|
78
|
|
|
->pipe(new CreateDigraph($this->graphvizProcessor, $input->display())) |
|
79
|
|
|
->pipe(new CreateClassDiagram($this->imageProcessor, $input->display())) |
|
80
|
|
|
->pipe(new SaveFile($this->writer, $input->outputFile(), $input->display())); |
|
81
|
|
|
|
|
82
|
|
|
$pipeline->process($input->directory()); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths