GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 99078a...9605c1 )
by Oanh
02:49
created

AskPasswordGetter::createQuestionHelper()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Server\Password;
9
10
use Deployer\Task\Context;
11
use Symfony\Component\Console\Helper\QuestionHelper;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use Symfony\Component\Console\Question\Question;
15
16
/**
17
 * Ask password getter
18
 *
19
 * @author Vitaliy Zhuk <[email protected]>
20
 */
21
class AskPasswordGetter implements PasswordGetterInterface
22
{
23
    /**
24
     * @var InputInterface
25
     */
26
    private $input;
27
28
    /**
29
     * @var OutputInterface
30
     */
31
    private $output;
32
33
    /**
34
     * Construct
35
     *
36
     * @param InputInterface  $input
37
     * @param OutputInterface $output
38
     */
39 4
    public function __construct(InputInterface $input, OutputInterface $output)
40
    {
41 4
        $this->input = $input;
42 4
        $this->output = $output;
43 4
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48 2
    public function getPassword($host, $user)
49
    {
50 2
        $askMessage = sprintf('[%s@%s] Password:', $user, $host);
51
52 2
        $questionHelper = $this->createQuestionHelper();
53 2
        $question = new Question($askMessage);
54 2
        $question->setHidden(true);
55
56 2
        return $questionHelper->ask($this->input, $this->output, $question);
57
    }
58
59
    /**
60
     * Create a lazy ask password getter with use context output and input interfaces
61
     *
62
     * @return CallablePasswordGetter
63
     */
64
    public static function createLazyGetter()
65
    {
66 3
        return new CallablePasswordGetter(function ($host, $user) {
67 1
            $context = Context::get();
68 1
            $output = $context->getOutput();
69 1
            $input = $context->getInput();
70
71 1
            $askPasswordGetter = new AskPasswordGetter($input, $output);
72
73 1
            return $askPasswordGetter->getPassword($host, $user);
74 3
        });
75
    }
76
77
    /**
78
     * Create question helper
79
     *
80
     * @return QuestionHelper
81
     */
82 2
    protected function createQuestionHelper()
83
    {
84 2
        return new QuestionHelper();
85
    }
86
}
87