GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AddKeyCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 6 1
A execute() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Bundle\ApiAuthBundle\Command\Storage;
6
7
use Damax\Bundle\ApiAuthBundle\Key\Factory;
8
use Damax\Bundle\ApiAuthBundle\Key\Storage\Writer as Storage;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputArgument;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Symfony\Component\Console\Style\SymfonyStyle;
14
15
final class AddKeyCommand extends Command
16
{
17
    protected static $defaultName = 'damax:api-auth:storage:add-key';
18
19
    private $factory;
20
    private $storage;
21
22
    public function __construct(Factory $factory, Storage $storage)
23
    {
24
        parent::__construct();
25
26
        $this->factory = $factory;
27
        $this->storage = $storage;
28
    }
29
30
    protected function configure()
31
    {
32
        $this
33
            ->setDescription('Add api key to storage.')
34
            ->addArgument('identity', InputArgument::REQUIRED, 'Identity of the key.')
35
            ->addArgument('ttl', InputArgument::OPTIONAL, 'Time to live in free form.', '1 week')
36
        ;
37
    }
38
39
    protected function execute(InputInterface $input, OutputInterface $output)
40
    {
41
        $io = new SymfonyStyle($input, $output);
42
43
        if (false === $ttl = strtotime($input->getArgument('ttl'), 0)) {
44
            $io->error('Invalid ttl.');
45
46
            return 1;
47
        }
48
49
        $key = $this->factory->createKey($input->getArgument('identity'), $ttl);
50
51
        $this->storage->add($key);
52
53
        $io->success('Key: ' . (string) $key);
54
    }
55
}
56