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 — master ( d3d564...b12eee )
by
unknown
02:02
created

SplArrayObject   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 10
eloc 19
dl 0
loc 106
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __get() 0 3 1
A offsetGet() 0 7 2
A __construct() 0 3 1
A isEmpty() 0 3 2
A merge() 0 8 1
A exchangeOffset() 0 13 3
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Spl\DataStructures;
15
16
// ------------------------------------------------------------------------
17
18
/**
19
 * O2System Standard PHP Libraries ArrayObject
20
 *
21
 * @package O2System\Core\SPL
22
 */
23
class SplArrayObject extends \ArrayObject
24
{
25
    use Traits\ArrayConversionTrait;
26
    use Traits\ArrayFunctionsTrait;
27
28
    // ------------------------------------------------------------------------
29
30
    /**
31
     * SplArrayObject::__construct
32
     *
33
     * @see http://php.net/manual/en/class.arrayobject.php
34
     *
35
     * @param array $array Initial Array
36
     * @param int   $flag  ArrayObject Flags
37
     *
38
     * @return SplArrayObject Returns an SplArrayObject object on success.
39
     */
40
    public function __construct(array $array = [], $flag = \ArrayObject::ARRAY_AS_PROPS)
41
    {
42
        parent::__construct($array, $flag);
43
    }
44
45
    // ------------------------------------------------------------------------
46
47
    /**
48
     * SplArrayObject::isEmpty
49
     *
50
     * Checks if the array storage is empty.
51
     *
52
     * @return bool
53
     */
54
    public function isEmpty()
55
    {
56
        return ($this->count() == 0 ? true : false);
57
    }
58
59
    // -----------------------------------------------------------------------
60
61
    /**
62
     * SplArrayObject::__get
63
     *
64
     * @see http://php.net/manual/en/arrayobject.offsetget.php
65
     *
66
     * @param string $offset The offset with the value.
67
     *
68
     * @return mixed The value at the specified index or false.
69
     */
70
    public function __get($offset)
71
    {
72
        return $this->offsetGet($offset);
73
    }
74
75
    // ------------------------------------------------------------------------
76
77
    public function offsetGet($offset)
78
    {
79
        if ($this->offsetExists($offset) === false) {
80
            return false;
81
        }
82
83
        return parent::offsetGet($offset);
84
    }
85
86
    // ------------------------------------------------------------------------
87
88
    /**
89
     * SplArrayObject::exchangeOffset
90
     *
91
     * Exchange the storage offset into camelcase
92
     *
93
     * @return array Returns the new array storage
94
     */
95
    public function exchangeOffset()
96
    {
97
        if ($this->count() > 0) {
98
            $camelcaseStorage = [];
99
100
            foreach ($this->getArrayCopy() as $offset => $value) {
101
                $camelcaseStorage[ camelcase($offset) ] = $value;
0 ignored issues
show
Bug introduced by
The function camelcase was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

101
                $camelcaseStorage[ /** @scrutinizer ignore-call */ camelcase($offset) ] = $value;
Loading history...
102
            }
103
104
            $this->exchangeArray($camelcaseStorage);
105
        }
106
107
        return $this->getArrayCopy();
108
    }
109
110
    // ------------------------------------------------------------------------
111
112
    /**
113
     * SplArrayObject::merge
114
     *
115
     * Merge array of values into the storage
116
     *
117
     * @param array $values Variable list of arrays to merge.
118
     *
119
     * @return array The array merged copy of the resulting array
120
     */
121
    public function merge(array $values)
122
    {
123
        $storage = $this->getArrayCopy();
124
        $storage = array_merge($storage, $values);
125
126
        $this->exchangeArray($storage);
127
128
        return $storage;
129
    }
130
}