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.
Completed
Push — master ( 70cc7c...69ad8e )
by Dmitri
02:13
created

AddKeyCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
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\Input\InputOption;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use Symfony\Component\Console\Style\SymfonyStyle;
15
16
class AddKeyCommand extends Command
17
{
18
    protected static $defaultName = 'damax:api-auth:storage:add-key';
19
20
    private $factory;
21
    private $storage;
22
23
    public function __construct(Factory $factory, Storage $storage)
24
    {
25
        parent::__construct();
26
27
        $this->factory = $factory;
28
        $this->storage = $storage;
29
    }
30
31
    protected function configure()
32
    {
33
        // 10 years.
34
        $ttl = 3600 * 24 * 365 * 10;
35
36
        $this
37
            ->setDescription('Add api key to storage.')
38
            ->addArgument('username', InputArgument::REQUIRED, 'Username for the key.')
39
            ->addOption('ttl', null, InputOption::VALUE_REQUIRED, 'Time to live in seconds.', $ttl)
40
        ;
41
    }
42
43
    protected function execute(InputInterface $input, OutputInterface $output)
44
    {
45
        $key = $this->factory->createKey($input->getArgument('username'), (int) $input->getOption('ttl'));
46
47
        $this->storage->add($key);
48
49
        (new SymfonyStyle($input, $output))->success('Key: ' . (string) $key);
50
    }
51
}
52