Passed
Branch develop (6d6783)
by BENARD
03:42
created

PlayerCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 9 1
A execute() 0 12 3
A __construct() 0 4 1
1
<?php
2
namespace VideoGamesRecords\DwhBundle\Command;
3
4
use Exception;
5
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...
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use VideoGamesRecords\DwhBundle\Service\Dwh\DwhPlayerHandler;
10
11
class PlayerCommand extends Command
12
{
13
    protected static $defaultName = 'vgr-dwh:player';
14
15
    private DwhPlayerHandler $dwhPlayerHandler;
16
17
    public function __construct(DwhPlayerHandler $dwhPlayerHandler)
18
    {
19
        $this->dwhPlayerHandler = $dwhPlayerHandler;
20
        parent::__construct();
21
    }
22
23
    protected function configure()
24
    {
25
        $this
26
            ->setName('vgr-dwh:player')
27
            ->setDescription('Command to update table vgr_dwh.player')
28
            ->addArgument(
29
                'function',
30
                InputArgument::REQUIRED,
31
                'Who do you want to do?'
32
            );
33
    }
34
35
    /**
36
     * @param InputInterface  $input
37
     * @param OutputInterface $output
38
     * @return int
39
     * @throws Exception
40
     */
41
    protected function execute(InputInterface $input, OutputInterface $output): int
42
    {
43
        $function = $input->getArgument('function');
44
        switch ($function) {
45
            case 'maj':
46
                $this->dwhPlayerHandler->process();
47
                break;
48
            case 'purge':
49
                $this->dwhPlayerHandler->purge();
50
                break;
51
        }
52
        return 0;
53
    }
54
}
55