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.

ResultSet   A
last analyzed

Complexity

Total Complexity 20

Size/Duplication

Total Lines 154
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 154
wmc 20
lcom 1
cbo 0
rs 10

18 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A map() 0 4 1
A filter() 0 4 1
A each() 0 8 2
A reduce() 0 4 1
A count() 0 4 1
A keys() 0 4 1
A values() 0 4 1
A current() 0 4 1
A next() 0 4 1
A key() 0 4 1
A valid() 0 4 1
A rewind() 0 4 1
A offsetExists() 0 4 1
A offsetGet() 0 4 1
A offsetSet() 0 4 1
A offsetUnset() 0 4 1
A toArray() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the PHPMongo package.
5
 *
6
 * (c) Dmytro Sokil <[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 Sokil\Mongo;
13
14
class ResultSet implements \Iterator, \Countable, \ArrayAccess
15
{
16
    protected $documents = array();
17
18
    public function __construct(array $documents = null)
19
    {
20
        if ($documents) {
21
            $this->documents = $documents;
22
        }
23
    }
24
25
    public function map($callable)
26
    {
27
        return new ResultSet(array_map($callable, $this->documents));
28
    }
29
30
    public function filter($callable)
31
    {
32
        return new ResultSet(array_filter($this->documents, $callable));
33
    }
34
35
    public function each($callable)
36
    {
37
        foreach ($this->documents as $id => $document) {
38
            call_user_func($callable, $document, $id, $this);
39
        }
40
41
        return $this;
42
    }
43
44
    /**
45
     *
46
     * @param callable $callable apply arguments [$accumulator, $document]
47
     * @param mixed $initial
48
     * @return mixed
49
     */
50
    public function reduce($callable, $initial = null)
51
    {
52
        return array_reduce($this->documents, $callable, $initial);
53
    }
54
55
    /**
56
     * Count documents in result set
57
     * @return int count
58
     */
59
    public function count()
60
    {
61
        return count($this->documents);
62
    }
63
64
    public function keys()
65
    {
66
        return array_keys($this->documents);
67
    }
68
69
    public function values()
70
    {
71
        return array_values($this->documents);
72
    }
73
74
    /**
75
     * Return the current element
76
     * @return array|\Sokil\Mongo\Document
77
     */
78
    public function current()
79
    {
80
        return current($this->documents);
81
    }
82
83
    /**
84
     * Move forward to next element
85
     * @return void Any returned value is ignored.
86
     */
87
    public function next()
88
    {
89
        next($this->documents);
90
    }
91
92
    /**
93
     * Return the key of the current element
94
     * @return scalar scalar on success, or NULL on failure.
95
     */
96
    public function key()
97
    {
98
        return key($this->documents);
99
    }
100
101
    /**
102
     * Checks if current position is valid
103
     * @return boolean The return value will be casted to boolean and then evaluated.
104
     * Returns TRUE on success or FALSE on failure.
105
     */
106
    public function valid()
107
    {
108
        return key($this->documents) !== null;
109
    }
110
111
    /**
112
     * Rewind the Iterator to the first element
113
     * @return void Any returned value is ignored.
114
     */
115
    public function rewind()
116
    {
117
        reset($this->documents);
118
    }
119
120
    /**
121
     * Whether a offset exists
122
     * @param mixed $offset
123
     * An offset to check for.
124
     * @return boolean TRUE on success or FALSE on failure.
125
     * The return value will be casted to boolean if non-boolean was returned.
126
     */
127
    public function offsetExists($offset)
128
    {
129
        return array_key_exists($offset, $this->documents);
130
    }
131
132
    /**
133
     * Offset to retrieve
134
     * @param mixed $offset The offset to retrieve.
135
     * @return array|\Sokil\Mongo\Document
136
     */
137
    public function offsetGet($offset)
138
    {
139
        return $this->documents[$offset];
140
    }
141
142
    /**
143
     * Offset to set
144
     * @param mixed $offset The offset to assign the value to.
145
     * @param mixed $value The value to set.
146
     * @return void No value is returned.
147
     */
148
    public function offsetSet($offset, $value)
149
    {
150
        $this->documents[$offset] = $value;
151
    }
152
153
    /**
154
     * Offset to unset
155
     * @param mixed $offset The offset to unset.
156
     * @return void No value is returned.
157
     */
158
    public function offsetUnset($offset)
159
    {
160
        unset($this->documents[$offset]);
161
    }
162
163
    public function toArray()
164
    {
165
        return $this->documents;
166
    }
167
}
168