Failed Conditions
Push — v7 ( 6a6683...1d7ef8 )
by Florent
03:11
created

JKULoaderCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A configure() 0 10 1
A execute() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace Jose\Component\Console\Command;
15
16
use Jose\Component\Core\Converter\JsonConverterInterface;
17
use Jose\Component\KeyManagement\JKUFactory;
18
use Symfony\Component\Console\Input\InputArgument;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
22
final class JKULoaderCommand extends AbstractObjectOutputCommand
23
{
24
    /**
25
     * @var JKUFactory
26
     */
27
    private $jkuFactory;
28
29
    public function __construct(JKUFactory $jkuFactory, JsonConverterInterface $jsonConverter, $name = null)
30
    {
31
        $this->jkuFactory = $jkuFactory;
32
        parent::__construct($jsonConverter, $name);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected function configure()
39
    {
40
        parent::configure();
41
        $this
42
            ->setName('keyset:load:jku')
43
            ->setDescription('Loads a key set from an url.')
44
            ->setHelp('This command will try to get a key set from an URL. The distant key set is a JWKSet.')
45
            ->addArgument('url', InputArgument::REQUIRED, 'The URL')
46
        ;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    protected function execute(InputInterface $input, OutputInterface $output)
53
    {
54
        $url = $input->getArgument('url');
55
        $result = $this->jkuFactory->loadFromUrl($url);
56
        $this->prepareJsonOutput($input, $output, $result);
57
    }
58
}
59