Passed
Push — develop ( 57a0ca...bea66a )
by BENARD
09:14
created

PurgeCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 10
c 0
b 0
f 0
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 4 1
A configure() 0 5 1
1
<?php
2
namespace ProjetNormandie\MessageBundle\Command;
3
4
use ProjetNormandie\MessageBundle\Repository\MessageRepository;
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class PurgeCommand extends Command
10
{
11
    protected static $defaultName = 'pn-message:purge';
12
13
    private MessageRepository $messageRepository;
14
15
    public function __construct(MessageRepository $messageRepository)
16
    {
17
        $this->messageRepository = $messageRepository;
18
        parent::__construct();
19
    }
20
21
    protected function configure()
22
    {
23
        $this
24
            ->setName('pn-message:purge')
25
            ->setDescription('Delete old messages')
26
        ;
27
    }
28
29
    /**
30
     * @param InputInterface  $input
31
     * @param OutputInterface $output
32
     * @return int
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output): int
35
    {
36
        $this->messageRepository->purge();
37
        return 0;
38
    }
39
}
40