Passed
Branch develop (38ee07)
by BENARD
05:37
created

PostTopWeekCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 18
c 1
b 0
f 0
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 8 2
A __construct() 0 4 1
A configure() 0 10 1
1
<?php
2
namespace VideoGamesRecords\CoreBundle\Command\Article;
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\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use VideoGamesRecords\CoreBundle\Service\Article\PostTopWeekHandler;
10
11
class PostTopWeekCommand extends Command
12
{
13
    protected static $defaultName = 'vgr-core:post-top-week';
14
15
    private PostTopWeekHandler $postTopWeekHandler;
16
17
    public function __construct(PostTopWeekHandler $postTopWeekHandler)
18
    {
19
        $this->postTopWeekHandler = $postTopWeekHandler;
20
        parent::__construct();
21
    }
22
23
    protected function configure()
24
    {
25
        $this
26
            ->setName('vgr-core:post-top-week')
27
            ->setDescription('Command post top week')
28
            ->addOption(
29
                'date',
30
                null,
31
                InputOption::VALUE_OPTIONAL,
32
                ''
33
            )
34
        ;
35
    }
36
37
    /**
38
     * @param InputInterface  $input
39
     * @param OutputInterface $output
40
     * @return int
41
     * @throws Exception
42
     */
43
    protected function execute(InputInterface $input, OutputInterface $output): int
44
    {
45
        $date = $input->getOption('date');
46
        if ($date === null) {
47
            $date = date('Y-m-d');
48
        }
49
        $this->postTopWeekHandler->handle($date);
50
        return Command::SUCCESS;
51
    }
52
}
53