ArrayUtils   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 31
wmc 4
lcom 0
cbo 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A objectToArray() 0 8 3
A removeKeys() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Oryzone PHPoAuthUserData package <https://github.com/Oryzone/PHPoAuthUserData>.
5
 *
6
 * (c) Oryzone, developed by Luciano Mammino <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace OAuth\UserData\Utils;
13
14
/**
15
 * Class ArrayUtils
16
 * @package OAuth\Utils
17
 */
18
class ArrayUtils
19
{
20
21
    /**
22
     * Utility method to convert an object to an array
23
     *
24
     * @param  object $object
25
     * @return array
26
     */
27
    public static function objectToArray($object)
28
    {
29
        if (!is_object($object) && !is_array($object)) {
30
            return $object;
31
        }
32
33
        return array_map('self::objectToArray', (array) $object);
34
    }
35
36
    /**
37
     * Utility method that allow to remove a list of keys from a given array.
38
     * This method does not modify the passed array but builds a new one.
39
     *
40
     * @param  array    $array
41
     * @param  string[] $keys
42
     * @return array
43
     */
44
    public static function removeKeys($array, $keys)
45
    {
46
        return array_diff_key($array, array_flip($keys));
47
    }
48
}
49