AuthenticateCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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