Passed
Push — develop ( 6aca70...d56297 )
by BENARD
02:32
created

PurgeCommandHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

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

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\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class PurgeCommandHandler extends Command
11
{
12
    protected static $defaultName = 'pn-message:purge';
13
14
    private MessageRepository $messageRepository;
15
16
    public function __construct(MessageRepository $messageRepository)
17
    {
18
        $this->messageRepository = $messageRepository;
19
        parent::__construct();
20
    }
21
22
    protected function configure()
23
    {
24
        $this
25
            ->setName('pn-message:purge')
26
            ->setDescription('Delete old messages')
27
        ;
28
    }
29
30
    /**
31
     * @param InputInterface  $input
32
     * @param OutputInterface $output
33
     * @return int
34
     */
35
    protected function execute(InputInterface $input, OutputInterface $output): int
36
    {
37
        $this->messageRepository->purge();
38
        return 0;
39
    }
40
}
41