RemoveCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Assimtech\DislogBundle\Command;
6
7
use Assimtech\Dislog\Handler\HandlerInterface;
8
use Assimtech\Sysexits;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Input\InputOption;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
class RemoveCommand extends Command
15
{
16
    protected static $defaultName = 'assimtech:dislog:remove';
17
18
    protected function configure()
19
    {
20
        $this
21
            ->setDescription('Remove old api call logs')
22
        ;
23
    }
24
25
    private $handler;
26
    private $maxAge;
27
28
    public function __construct(
29
        HandlerInterface $handler,
30
        int $maxAge
31
    ) {
32
        parent::__construct();
33
34
        $this->handler = $handler;
35
        $this->maxAge = $maxAge;
36
    }
37
38
    protected function execute(
39
        InputInterface $input,
40
        OutputInterface $output
41
    ): int {
42
        $this->handler->remove($this->maxAge);
43
44
        return Sysexits::EX_OK;
45
    }
46
}
47