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

PurgeCommandHandler::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 2
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