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.

LookupKeyCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A execute() 0 17 2
A configure() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Bundle\ApiAuthBundle\Command\Storage;
6
7
use Damax\Bundle\ApiAuthBundle\Key\Storage\KeyNotFound;
8
use Damax\Bundle\ApiAuthBundle\Key\Storage\Reader 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 LookupKeyCommand extends Command
16
{
17
    protected static $defaultName = 'damax:api-auth:storage:lookup-key';
18
19
    private $storage;
20
21
    public function __construct(Storage $storage)
22
    {
23
        parent::__construct();
24
25
        $this->storage = $storage;
26
    }
27
28
    protected function configure()
29
    {
30
        $this
31
            ->setDescription('Lookup api key in storage.')
32
            ->addArgument('key', InputArgument::REQUIRED, 'Api key.')
33
        ;
34
    }
35
36
    protected function execute(InputInterface $input, OutputInterface $output)
37
    {
38
        $io = new SymfonyStyle($input, $output);
39
40
        try {
41
            $key = $this->storage->get($input->getArgument('key'));
42
        } catch (KeyNotFound $e) {
43
            $io->error('Key not found.');
44
45
            return 1;
46
        }
47
48
        $io->writeln('');
49
        $io->table([], [
50
            ['Key', (string) $key],
51
            ['Identity', $key->identity()],
52
            ['TTL', $key->ttl()],
53
        ]);
54
    }
55
}
56