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.

ArrayManager::arrayValue()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 8
cp 0
rs 9.2
cc 4
eloc 7
nc 3
nop 2
crap 20
1
<?php
2
/**
3
 * @author Sergii Bondarenko, <[email protected]>
4
 */
5
namespace Behat\SoapExtension\Utils;
6
7
/**
8
 * Trait ArrayManager.
9
 *
10
 * @package Behat\SoapExtension\Utils
11
 */
12
trait ArrayManager
13
{
14
    /**
15
     * @param object $object
16
     *
17
     * @return array
18
     */
19
    public static function objectToArray($object)
20
    {
21
        return json_decode(json_encode($object), true);
22
    }
23
24
    /**
25
     * Retrieves a value from a nested array.
26
     *
27
     * @param array $array
28
     *   An array from which the value will be got.
29
     * @param array $parents
30
     *   An array of keys, starting with the outermost key.
31
     *
32
     * @return mixed
33
     */
34
    public static function arrayValue(array $array, array $parents)
35
    {
36
        foreach ($parents as $parent) {
37
            if (is_array($array) && array_key_exists($parent, $array)) {
38
                $array = $array[$parent];
39
            } else {
40
                return null;
41
            }
42
        }
43
44
        return $array;
45
    }
46
}
47