GenerateDTOCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 13 2
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\DTO\Console;
15
16
use Micro\Plugin\DTO\Facade\DTOFacadeInterface;
17
use Symfony\Component\Console\Command\Command;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Command\Command 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...
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Output\OutputInterface;
20
21
class GenerateDTOCommand extends Command
22
{
23
    protected const HELP = 'Generate DTO classes.';
24
    protected static $defaultName = 'micro:dto:generate';
25
26 2
    public function __construct(
27
        private readonly DTOFacadeInterface $DTOFacade
28
    ) {
29 2
        parent::__construct(self::$defaultName);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35 2
    protected function execute(InputInterface $input, OutputInterface $output): int
36
    {
37 2
        $output->writeln('<info> Generate DTO classes... </info>');
38
        try {
39 2
            $this->DTOFacade->generate();
40 1
            $output->writeln('<info> Success!</info>');
41 1
        } catch (\Throwable $e) {
42 1
            $output->writeln(sprintf('<error> %s </error>', $e->getMessage()));
43
44 1
            throw $e;
45
        }
46
47 1
        return Command::SUCCESS;
48
    }
49
}
50