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

X5ULoaderCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 3
dl 0
loc 44
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\X5UFactory;
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 X5ULoaderCommand extends AbstractObjectOutputCommand
23
{
24
    /**
25
     * @var X5UFactory
26
     */
27
    private $x5uFactory;
28
29
    /**
30
     * X5ULoaderCommand constructor.
31
     *
32
     * @param X5UFactory $x5uFactory
33
     * @param JsonConverterInterface $jsonConverter
34
     * @param null $name
35
     */
36
    public function __construct(X5UFactory $x5uFactory, JsonConverterInterface $jsonConverter, $name = null)
37
    {
38
        $this->x5uFactory = $x5uFactory;
39
        parent::__construct($jsonConverter, $name);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    protected function configure()
46
    {
47
        parent::configure();
48
        $this
49
            ->setName('keyset:load:x5u')
50
            ->setDescription('Loads a key set from an url.')
51
            ->setHelp('This command will try to get a key set from an URL. The distant key set is list of X.509 certificates.')
52
            ->addArgument('url', InputArgument::REQUIRED, 'The URL')
53
        ;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    protected function execute(InputInterface $input, OutputInterface $output)
60
    {
61
        $url = $input->getArgument('url');
62
        $result = $this->x5uFactory->loadFromUrl($url);
63
        $this->prepareJsonOutput($input, $output, $result);
64
    }
65
}
66