Completed
Push — feature/EVO-4597-rabbitmq-hand... ( 6e503b...616297 )
by
unknown
52:22 queued 46:35
created

AuthenticationKeyFinderCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 54
ccs 20
cts 20
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addService() 0 5 1
A configure() 0 12 1
A execute() 0 9 1
1
<?php
2
/**
3
 * Class AuthenticationKeyFinderCommand
4
 */
5
6
namespace Graviton\SecurityBundle\Command;
7
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Logger\ConsoleLogger;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Symfony\Component\DependencyInjection\ContainerInterface;
14
15
/**
16
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
17
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
18
 * @link     http://swisscom.ch
19
 */
20
class AuthenticationKeyFinderCommand extends Command
21
{
22
    /**
23
     * @var array
24
     */
25
    private $strategies = array();
26
27
    /**
28
     * @param string $service add strategy services to show
29
     *
30
     * @return void
31
     */
32 2
    public function addService($service)
33
    {
34 2
        $this->strategies[] = $service;
35 2
        $this->strategies = array_unique($this->strategies);
36 2
    }
37
38
    /**
39
     * {@inheritDoc}
40
     *
41
     * @return void
42
     */
43 2
    protected function configure()
44
    {
45 2
        $this
46 2
            ->setName('graviton:security:authenication:keyfinder:strategies')
47 2
            ->setDescription('Shows a list of available keyfinder strategies.')
48 2
            ->addOption(
49 2
                'list',
50 2
                'l',
51 2
                InputOption::VALUE_NONE,
52
                'If set, it will provide a list of available strategies.'
53 2
            );
54 2
    }
55
56
    /**
57
     * {@inheritDoc}
58
     *
59
     * @param InputInterface  $input  input from cli
60
     * @param OutputInterface $output output to cli
61
     *
62
     * @return void
63
     */
64 2
    protected function execute(InputInterface $input, OutputInterface $output)
65
    {
66 2
        $output->writeln('<info>Following strategies to extract an authentication key are available:</info>');
67 2
        $output->writeln(
68
            "<info>\t* " .
69 2
            implode(PHP_EOL . "\t* ", $this->strategies) .
70
            "</info>"
71 2
        );
72 2
    }
73
}
74