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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 35
ccs 0
cts 10
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A objectToArray() 0 4 1
A arrayValue() 0 12 4
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