TransferGenerateCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 16
c 1
b 0
f 1
dl 0
loc 60
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A configure() 0 6 1
A execute() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jellyfish\Transfer\Command;
6
7
use Jellyfish\Transfer\TransferCleanerInterface;
8
use Jellyfish\Transfer\TransferGeneratorInterface;
9
use Psr\Log\LoggerInterface;
10
use Symfony\Component\Console\Command\Command;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
class TransferGenerateCommand extends Command
15
{
16
    public const NAME = 'transfer:generate';
17
    public const DESCRIPTION = 'Generate transfer classes and factories';
18
19
    /**
20
     * @var \Psr\Log\LoggerInterface
21
     */
22
    protected $logger;
23
24
    /**
25
     * @var \Jellyfish\Transfer\TransferGeneratorInterface
26
     */
27
    protected $transferGenerator;
28
29
    /**
30
     * @var \Jellyfish\Transfer\TransferCleanerInterface
31
     */
32
    protected $transferCleaner;
33
34
    /**
35
     * @param \Jellyfish\Transfer\TransferGeneratorInterface $transferGenerator
36
     * @param \Jellyfish\Transfer\TransferCleanerInterface $transferCleaner
37
     * @param \Psr\Log\LoggerInterface $logger
38
     */
39
    public function __construct(
40
        TransferGeneratorInterface $transferGenerator,
41
        TransferCleanerInterface $transferCleaner,
42
        LoggerInterface $logger
43
    ) {
44
        $this->transferGenerator = $transferGenerator;
45
        $this->transferCleaner = $transferCleaner;
46
        $this->logger = $logger;
47
48
        parent::__construct();
49
    }
50
51
    /**
52
     * @return void
53
     */
54
    protected function configure(): void
55
    {
56
        parent::configure();
57
58
        $this->setName(static::NAME);
59
        $this->setDescription(static::DESCRIPTION);
60
    }
61
62
    /**
63
     * @param \Symfony\Component\Console\Input\InputInterface $input
64
     * @param \Symfony\Component\Console\Output\OutputInterface $output
65
     *
66
     * @return int|null
67
     */
68
    protected function execute(InputInterface $input, OutputInterface $output): ?int
69
    {
70
        $this->transferCleaner->clean();
71
        $this->transferGenerator->generate();
72
73
        return null;
74
    }
75
}
76