Failed Conditions
Push — master ( 6fca32...0b1cfb )
by Michał
02:10
created

src/Command/Login.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace BarenoteCli\Command;
3
4
use BarenoteCli\BarenoteApplication;
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Helper\QuestionHelper;
7
use Symfony\Component\Console\Input\ArrayInput;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Console\Question\Question;
11
12
/**
13
 * Class LoginCommand
14
 * @package BarenoteCli\Command
15
 * @method BarenoteApplication getApplication()
16
 */
17
class Login extends Command
18
{
19
    /**
20
     * @throws \Symfony\Component\Console\Exception\InvalidArgumentException
21
     */
22
    protected function configure()
23
    {
24
        $this
25
            ->setName('barenote:login')
26
            ->setDescription('Fetches token from the API.')
27
            ->setHelp('This command allows you to authenticate against API...')
28
            ->setHidden(true);
29
    }
30
    
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $client = $this->getApplication()->getClient();
34
        /** @var QuestionHelper $helper */
35
        $helper = $this->getHelper('question');
36
        
37
        $question = new Question('Please enter your username' . PHP_EOL, 'dummy');
38
        $question->setAutocompleterValues(['dummy']);
39
        $username = $helper->ask($input, $output, $question);
40
        
41
        $question = new Question('Please enter your password, I promise I won\'t do enything malicious' . PHP_EOL, 'account');
42
        $question->setAutocompleterValues(['account']);
43
        $password = $helper->ask($input, $output, $question);
44
        
45
        $client->authenticate($username, $password);
46
        
47
        $menu = $this->getApplication()->find('barenote:postauth:menu')->run(new ArrayInput([]), $output);
0 ignored issues
show
$menu is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
48
    }
49
}