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
Pull Request — master (#1061)
by Maxim
04:23 queued 01:35
created

Config::merge()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 5

Importance

Changes 0
Metric Value
cc 5
eloc 12
nc 5
nop 2
dl 0
loc 22
ccs 13
cts 13
cp 1
crap 5
rs 8.6737
c 0
b 0
f 0
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\Type;
9
10
class Config
11
{
12
    /**
13
     * Recursively merge two config arrays with a specific behavior:
14
     *
15
     * 1. scalar values are overridden
16
     * 2. array values are extended uniquely if all keys are numeric
17
     * 3. all other array values are merged
18
     *
19
     * @param array $original
20
     * @param array $override
21
     * @return array
22
     * @see http://stackoverflow.com/a/36366886/6812729
23
     */
24 2
    public static function merge(array $original, array $override)
25
    {
26 2
        foreach ($override as $key => $value) {
27 2
            if (isset($original[$key])) {
28 2
                if (!is_array($original[$key])) {
29
                    // Override scalar value
30 2
                    $original[$key] = $value;
31 2
                } elseif (array_keys($original[$key]) === range(0, count($original[$key]) - 1)) {
32
                    // Uniquely append to array with numeric keys
33 2
                    $original[$key] = array_unique(array_merge($original[$key], $value));
34 2
                } else {
35
                    // Merge all other arrays
36 2
                    $original[$key] = Config::merge($original[$key], $value);
37
                }
38 2
            } else {
39
                // Simply add new key/value
40 2
                $original[$key] = $value;
41
            }
42 2
        }
43
44 2
        return $original;
45
    }
46
}
47