Completed
Pull Request — master (#32)
by Yann
03:35
created

ArchiveTokenCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Yokai\SecurityTokenBundle\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Yokai\SecurityTokenBundle\Archive\ArchivistInterface;
10
11
/**
12
 * @author Yann Eugoné <[email protected]>
13
 */
14
class ArchiveTokenCommand extends Command
15
{
16
    /**
17
     * @var ArchivistInterface
18
     */
19 2
    private $archivist;
20
21
    public function __construct(ArchivistInterface $archivist)
22 2
    {
23 2
        $this->archivist = $archivist;
24 2
        parent::__construct();
25
    }
26 2
27
    /**
28
     * @inheritDoc
29
     */
30
    protected function configure(): void
31 2
    {
32
        $this
33 2
            ->setName('yokai:security-token:archive')
34
            ->addOption('purpose', null, InputOption::VALUE_OPTIONAL, 'Filter tokens to archive on purpose.')
35 2
        ;
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    protected function execute(InputInterface $input, OutputInterface $output): int
42
    {
43 2
        $purpose = $input->getOption('purpose');
44
45 2
        $count = $this->archivist->archive($purpose);
46
47 2
        $output->writeln(
48 2
            sprintf('<info>Successfully archived <comment>%d</comment> security token(s).</info>', $count)
49
        );
50 2
51
        return 0;
52
    }
53
}
54