MontealegreLuis /
phuml
| 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\Console\Commands; |
||
| 9 | |||
| 10 | use InvalidArgumentException; |
||
| 11 | use PhUml\Configuration\ClassDiagramBuilder; |
||
| 12 | use PhUml\Configuration\ClassDiagramConfiguration; |
||
| 13 | use PhUml\Parser\CodebaseDirectory; |
||
| 14 | use Symfony\Component\Console\Input\InputArgument; |
||
|
0 ignored issues
–
show
|
|||
| 15 | use Symfony\Component\Console\Input\InputInterface; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Input\InputInterface 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 16 | use Symfony\Component\Console\Input\InputOption; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Input\InputOption 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 17 | use Symfony\Component\Console\Output\OutputInterface; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Output\OutputInterface 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 18 | |||
| 19 | /** |
||
| 20 | * This command will generate a UML class diagram by reading an OO codebase |
||
| 21 | * |
||
| 22 | * This command has 2 required arguments |
||
| 23 | * |
||
| 24 | * 1. `directory`. The path where your codebase lives |
||
| 25 | * 2. `output`. The path to where the generated `png` image will be saved |
||
| 26 | * |
||
| 27 | * There is 1 option specific to this command |
||
| 28 | * |
||
| 29 | * 1. `processor`. The command to be used to create the `png` image, it can be either `neato` or `dot` |
||
| 30 | * This is the only required option |
||
| 31 | * |
||
| 32 | * @see WithDigraphConfiguration::addDigraphOptions() for more details about the rest of the options |
||
| 33 | */ |
||
| 34 | class GenerateClassDiagramCommand extends GeneratorCommand |
||
| 35 | { |
||
| 36 | use WithDigraphConfiguration; |
||
| 37 | |||
| 38 | 72 | /** @throws InvalidArgumentException */ |
|
| 39 | protected function configure(): void |
||
| 40 | { |
||
| 41 | 72 | $this |
|
| 42 | 72 | ->setName('phuml:diagram') |
|
| 43 | 72 | ->setDescription('Generate a class diagram scanning the given directory') |
|
| 44 | ->setHelp( |
||
| 45 | 72 | <<<HELP |
|
| 46 | Example: |
||
| 47 | php bin/phuml phuml:diagram -r -a -p neato ./src out.png |
||
| 48 | |||
| 49 | This command will look for PHP files within the `./src` directory and its sub-directories. |
||
| 50 | It will extract associations from constructor parameters and attributes. |
||
| 51 | It will generate the class diagram using the `neato` processor |
||
| 52 | It will save the diagram to the file `out.png`. |
||
| 53 | HELP |
||
| 54 | 72 | ) |
|
| 55 | 72 | ->addArgument( |
|
| 56 | 72 | 'directory', |
|
| 57 | 72 | InputArgument::REQUIRED, |
|
| 58 | 'The directory to be scanned to generate the class diagram' |
||
| 59 | 72 | ) |
|
| 60 | 72 | ->addArgument( |
|
| 61 | 72 | 'output', |
|
| 62 | 72 | InputArgument::REQUIRED, |
|
| 63 | 'The file name for your class diagram' |
||
| 64 | 72 | ) |
|
| 65 | 72 | ->addOption( |
|
| 66 | 72 | 'processor', |
|
| 67 | 72 | 'p', |
|
| 68 | 72 | InputOption::VALUE_REQUIRED, |
|
| 69 | 'Choose between the neato and dot processors' |
||
| 70 | ) |
||
| 71 | 72 | ; |
|
| 72 | 72 | $this->addDigraphOptions($this); |
|
| 73 | } |
||
| 74 | 21 | ||
| 75 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 76 | 21 | { |
|
| 77 | 21 | $generatorInput = new GeneratorInput($input->getArguments(), $input->getOptions()); |
|
| 78 | $codebasePath = $generatorInput->directory(); |
||
| 79 | 21 | $classDiagramPath = $generatorInput->outputFile(); |
|
| 80 | |||
| 81 | 21 | $builder = new ClassDiagramBuilder(new ClassDiagramConfiguration($generatorInput->options())); |
|
| 82 | 21 | ||
| 83 | $codeFinder = $builder->codeFinder(); |
||
| 84 | 18 | $codeFinder->addDirectory(CodebaseDirectory::from($codebasePath)); |
|
| 85 | 18 | ||
| 86 | $classDiagramGenerator = $builder->classDiagramGenerator(); |
||
| 87 | 18 | $classDiagramGenerator->attach($this->display); |
|
| 88 | |||
| 89 | 18 | $classDiagramGenerator->generate($codeFinder, $classDiagramPath); |
|
| 90 | |||
| 91 | return self::SUCCESS; |
||
| 92 | } |
||
| 93 | } |
||
| 94 |
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