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.

CustomOption   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 88.24%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 31
c 1
b 0
f 0
rs 10
ccs 15
cts 17
cp 0.8824
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A applyOverrides() 0 12 4
A castValueToPhpType() 0 9 3
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\Console;
9
10
use Deployer\Host\Host;
11
12
trait CustomOption
13
{
14
    /**
15
     * @param Host[] $hosts
16
     * @param string[] $options
17
     */
18 12
    protected function applyOverrides(array $hosts, array $options)
19
    {
20 12
        $override = [];
21 12
        foreach ($options as $option) {
22 1
            list($name, $value) = explode('=', $option);
23 1
            $value = $this->castValueToPhpType(trim($value));
24 1
            $override[trim($name)] = $value;
25
        }
26
27 12
        foreach ($hosts as $host) {
28 12
            foreach ($override as $key => $value) {
29 1
                $host->set($key, $value);
30
            }
31
        }
32 12
    }
33
34 1
    protected function castValueToPhpType($value)
35
    {
36 1
        switch ($value) {
37 1
            case 'true':
38
                return true;
39 1
            case 'false':
40
                return false;
41
            default:
42 1
                return $value;
43
        }
44
    }
45
}
46