TokenCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace CL\ComposerInit;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use GuzzleHttp\Client;
10
11
/**
12
 * @author    Ivan Kerin <[email protected]>
13
 * @copyright (c) 2014 Clippings Ltd.
14
 * @license   http://spdx.org/licenses/BSD-3-Clause
15
 */
16
class TokenCommand extends Command
17
{
18
    /**
19
     * @var Token
20
     */
21
    private $token;
22
23
    /**
24
     * @param Token $token
25
     */
26 1
    public function __construct(Token $token)
27
    {
28 1
        parent::__construct();
29
30 1
        $this->token = $token;
31 1
    }
32
33 1
    public function getToken()
34
    {
35 1
        return $this->token;
36
    }
37
38 1
    protected function configure()
39
    {
40 1
        $this
41 1
            ->setName('token')
42 1
            ->setDescription('Set a token for github')
43 1
            ->addArgument(
44 1
                'token',
45 1
                InputArgument::REQUIRED,
46
                'Github application token'
47 1
            );
48 1
    }
49
50
    /**
51
     * @param  InputInterface  $input
52
     * @param  OutputInterface $output
53
     */
54 1
    protected function execute(InputInterface $input, OutputInterface $output)
55
    {
56 1
        $token = $input->getArgument('token');
57
58 1
        $this->token->set($token);
59
60 1
        $output->writeln("Token saved to {$this->token->getFilename()}");
61 1
    }
62
}
63