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.
Passed
Push — master ( 38eb10...d581fd )
by Anton
02:47
created

IOArguments   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 38
dl 0
loc 56
rs 10
c 0
b 0
f 0
wmc 16

2 Methods

Rating   Name   Duplication   Size   Complexity  
B collect() 0 37 10
A verbosity() 0 15 6
1
<?php
2
3
declare(strict_types=1);
4
5
/* (c) Anton Medvedev <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Deployer\Ssh;
12
13
use Deployer\Exception\Exception;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
class IOArguments
18
{
19
    public static function collect(InputInterface $input, OutputInterface $output): array
20
    {
21
        $arguments = [];
22
        foreach ($input->getOptions() as $name => $value) {
23
            if (!$input->getOption($name)) {
24
                continue;
25
            }
26
            if ($name === 'file') {
27
                $arguments[] = "--file";
28
                $arguments[] = ltrim($value, '=');
29
                continue;
30
            }
31
            if (in_array($name, ['verbose'], true)) {
32
                continue;
33
            }
34
            if (!is_array($value)) {
35
                $value = [$value];
36
            }
37
            foreach ($value as $v) {
38
                if (is_bool($v)) {
39
                    $arguments[] = "--$name";
40
                    continue;
41
                }
42
43
                $arguments[] = "--$name";
44
                $arguments[] = $v;
45
            }
46
        }
47
48
        if ($output->isDecorated()) {
49
            $arguments[] = '--decorated';
50
        }
51
        $verbosity = self::verbosity($output->getVerbosity());
52
        if (!empty($verbosity)) {
53
            $arguments[] = $verbosity;
54
        }
55
        return $arguments;
56
    }
57
58
    private static function verbosity(int $verbosity): string
59
    {
60
        switch ($verbosity) {
61
            case OutputInterface::VERBOSITY_QUIET:
62
                return '-q';
63
            case OutputInterface::VERBOSITY_NORMAL:
64
                return '';
65
            case OutputInterface::VERBOSITY_VERBOSE:
66
                return '-v';
67
            case OutputInterface::VERBOSITY_VERY_VERBOSE:
68
                return '-vv';
69
            case OutputInterface::VERBOSITY_DEBUG:
70
                return '-vvv';
71
            default:
72
                throw new Exception('Unknown verbosity level: ' . $verbosity);
73
        }
74
    }
75
}
76