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.

Helper::array_intersect_recursive()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5.0342

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 9
c 1
b 0
f 0
nc 5
nop 2
dl 0
loc 14
ccs 8
cts 9
cp 0.8889
crap 5.0342
rs 9.6111
1
<?php
2
3
namespace Awin\ReportTask\Bundle\ReportBundle\Utility;
4
5
/**
6
 * Quick utility class for the static method usuage
7
 *
8
 * @date       25/06/2017
9
 * @time       22:19
10
 * @author     Peng Yue <[email protected]>
11
 * @copyright  2004-2017 Peng Yue
12
 */
13
14
class Helper
15
{
16
    /**
17
     * recursively intersect arrays
18
     *
19
     * @param array $array1
20
     * @param array $array2
21
     *
22
     * @return array
23
     */
24 2
    public static function array_intersect_recursive($array1, $array2)
25
    {
26 2
        foreach($array1 as $key => $value) {
27 2
            if (!isset($array2[$key])) {
28
                unset($array1[$key]);
29
            } else {
30 2
                if (is_array($array1[$key])) {
31 1
                    $array1[$key] = self::array_intersect_recursive($array1[$key], $array2[$key]);
32 2
                } elseif ($array2[$key] !== $value) {
33 2
                    unset($array1[$key]);
34
                }
35
            }
36
        }
37 2
        return $array1;
38
    }
39
}