AuthenticateCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 4
dl 0
loc 32
ccs 0
cts 16
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 4 1
A execute() 0 15 1
1
<?php
2
namespace Graceland\SafeInCloud\Commands;
3
4
use Graceland\SafeInCloud\ApiClient;
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Question\Question;
9
10
class AuthenticateCommand extends Command
11
{
12
    protected $client;
13
14
    public function __construct(ApiClient $client)
15
    {
16
        parent::__construct();
17
18
        $this->client = $client;
19
    }
20
21
    protected function configure()
22
    {
23
        $this->setName('authenticate')->setDescription('Authenticate against SafeInCloud');
24
    }
25
26
    protected function execute(InputInterface $input, OutputInterface $output)
27
    {
28
        $helper   = $this->getHelper('question');
29
        $question = new Question('Enter your password:');
30
31
        $question->setHidden(true);
32
        $question->setHiddenFallback(false);
33
34
        $password = $helper->ask($input, $output, $question);
35
36
        $this->client->doHandshake();
37
        $output->writeln($this->client->authenticate($password));
38
39
        return 0;
40
    }
41
}
42