RemoveKeyCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Bundle\ApiAuthBundle\Command\Storage;
6
7
use Damax\Bundle\ApiAuthBundle\Key\Storage\Writer as Storage;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
use Symfony\Component\Console\Style\SymfonyStyle;
13
14
final class RemoveKeyCommand extends Command
15
{
16
    protected static $defaultName = 'damax:api-auth:storage:remove-key';
17
18
    private $storage;
19
20
    public function __construct(Storage $storage)
21
    {
22
        parent::__construct();
23
24
        $this->storage = $storage;
25
    }
26
27
    protected function configure()
28
    {
29
        $this
30
            ->setDescription('Remove api key from storage.')
31
            ->addArgument('key', InputArgument::REQUIRED, 'Api key.')
32
        ;
33
    }
34
35
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        $this->storage->remove((string) $input->getArgument('key'));
38
39
        (new SymfonyStyle($input, $output))->success('Done');
40
    }
41
}
42