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
Push — develop ( a1ecb7...a37349 )
by Sébastien
02:34
created

Factory::getArrayForItems()   B

Complexity

Conditions 7
Paths 6

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 7.1782

Importance

Changes 0
Metric Value
cc 7
eloc 12
nc 6
nop 1
dl 0
loc 17
ccs 11
cts 13
cp 0.8462
crap 7.1782
rs 8.2222
c 0
b 0
f 0
1
<?php
2
/**
3
 * Novactive Collection.
4
 *
5
 * @author    Luke Visinoni <[email protected], [email protected]>
6
 * @author    Sébastien Morel <[email protected], [email protected]>
7
 * @copyright 2017 Novactive
8
 * @license   MIT
9
 */
10
11
namespace Novactive\Collection;
12
13
use Traversable;
14
15
/**
16
 * Class Factory.
17
 */
18
class Factory
19
{
20
    /**
21
     * @param Traversable|array $items
22
     * @param string            $className
23
     *
24
     * @return Collection
25
     */
26 123
    public static function create($items = [], $className = 'Novactive\Collection\Collection')
27
    {
28 123
        $options = null;
29 123
        if (getenv('DEBUG_COLLECTION_CLASS') && getenv('DEBUG_COLLECTION_CLASS') != '') {
30
            $className = getenv('DEBUG_COLLECTION_CLASS');
31
        }
32
33 123
        return new $className(static::getArrayForItems($items), $options);
34
    }
35
36
    /**
37
     * @param $items
38
     *
39
     * @return array
40
     */
41 123
    public static function getArrayForItems($items)
42
    {
43 123
        if ($items instanceof Collection) {
44 8
            return $items->toArray();
45 121
        } elseif (is_array($items)) {
46 119
            return $items;
47 5
        } elseif ($items instanceof Traversable) {
48 1
            return iterator_to_array($items);
49 4
        } elseif (is_string($items)) {
50 4
            $json = json_decode($items, true);
51 4
            if (is_array($json) && json_last_error() == JSON_ERROR_NONE) {
52 4
                return $json;
53
            }
54
        }
55
56
        return (array)$items;
57
    }
58
}
59