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 ( 1dba41...0db4d1 )
by Anton
02:05
created

Option   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 68
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0
wmc 9
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
B toString() 0 39 5
A generatePartialOption() 0 22 4
1
<?php declare(strict_types=1);
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\Console\Input;
9
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Input\InputOption;
12
13
final class Option
14
{
15 33
    public static function toString(
16
        InputInterface $input,
17
        InputOption $option
18
    ): string {
19 33
        $name = $option->getName();
20
21 33
        if (!$option->acceptValue()) {
22 5
            return \sprintf(
23 5
                '--%s',
24
                $name
25
            );
26
        }
27
28 28
        if (!$option->isArray()) {
29 16
            return self::generatePartialOption(
30
                $option,
31
                $name,
32 16
                $input->getOption($name)
33
            );
34
        }
35
36
        /** @var string[] $outputs */
37 12
        $outputs = [];
38 12
        foreach ($input->getOption($name) as $value) {
39 12
            $value = self::generatePartialOption(
40
                $option,
41
                $name,
42
                $value
43
            );
44
45 12
            if ($value === '') {
46 4
                continue;
47
            }
48
49 9
            $outputs[] = $value;
50
        }
51
52 12
        return \implode(' ', $outputs);
53
    }
54
55
    /**
56
     * @param null|string $value
57
     */
58 28
    private static function generatePartialOption(
59
        InputOption $option,
60
        string $name,
61
        $value
62
    ): string {
63 28
        if (\null !== $value && \strlen($value) !== 0) {
64 14
            return \sprintf(
65 14
                '--%s=%s',
66
                $name,
67
                $value
68
            );
69
        }
70
71 16
        if ($option->isValueOptional()) {
72 6
            return \sprintf(
73 6
                '--%s',
74
                $name
75
            );
76
        }
77
78 10
        return '';
79
    }
80
}
81