PersistentCollection::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\ODM\CouchDB;
4
5
use Doctrine\Common\Collections\Collection;
6
7
/**
8
 * Persistent collection class
9
 *
10
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
11
 * @link        www.doctrine-project.com
12
 * @since       1.0
13
 * @author      Benjamin Eberlei <[email protected]>
14
 */
15
abstract class PersistentCollection implements Collection
16
{
17
    /** @var Collection */
18
    protected $col;
19
    protected $changed = false;
20
    public $isInitialized = false;
21
22
    abstract public function initialize();
23
24
    public function changed()
25
    {
26
        return $this->changed;
27
    }
28
29
    public function takeSnapshot()
30
    {
31
        $this->changed = false;
32
    }
33
34
    public function unwrap()
35
    {
36
        return $this->col;
37
    }
38
39
    public function add($element)
40
    {
41
        $this->initialize();
42
        $this->changed = true;
43
        return $this->col->add($element);
44
    }
45
46
    public function clear()
47
    {
48
        $this->initialize();
49
        $this->changed = true;
50
        return $this->col->clear();
51
    }
52
53
    public function contains($element)
54
    {
55
        $this->initialize();
56
        return $this->col->contains($element);
57
    }
58
59
    public function containsKey($key)
60
    {
61
        $this->initialize();
62
        return $this->col->containsKey($key);
63
    }
64
65
    public function count()
66
    {
67
        $this->initialize();
68
        return $this->col->count();
69
    }
70
71
    public function current()
72
    {
73
        $this->initialize();
74
        return $this->col->current();
75
    }
76
77
    public function exists(\Closure $p)
78
    {
79
        $this->initialize();
80
        return $this->col->exists($p);
81
    }
82
83
    public function filter(\Closure $p)
84
    {
85
        $this->initialize();
86
        return $this->col->filter($p);
87
    }
88
89
    public function first()
90
    {
91
        $this->initialize();
92
        return $this->col->first();
93
    }
94
95
    public function forAll(\Closure $p)
96
    {
97
        $this->initialize();
98
        return $this->col->forAll($p);
99
    }
100
101
    public function get($key)
102
    {
103
        $this->initialize();
104
        return $this->col->get($key);
105
    }
106
107
    public function getIterator()
108
    {
109
        $this->initialize();
110
        return $this->col->getIterator();
111
    }
112
113
    public function getKeys()
114
    {
115
        $this->initialize();
116
        return $this->col->getKeys();
117
    }
118
119
    public function getValues()
120
    {
121
        $this->initialize();
122
        return $this->col->getValues();
123
    }
124
125
    public function indexOf($element)
126
    {
127
        $this->initialize();
128
        return $this->col->indexOf($element);
129
    }
130
131
    public function isEmpty()
132
    {
133
        $this->initialize();
134
        return $this->col->isEmpty();
135
    }
136
137
    public function key()
138
    {
139
        $this->initialize();
140
        return $this->col->key();
141
    }
142
143
    public function last()
144
    {
145
        $this->initialize();
146
        return $this->col->last();
147
    }
148
149
    public function map(\Closure $func)
150
    {
151
        $this->initialize();
152
        return $this->col->map($func);
153
    }
154
155
    public function next()
156
    {
157
        $this->initialize();
158
        return $this->col->next();
159
    }
160
161
    public function offsetExists($offset)
162
    {
163
        $this->initialize();
164
        return $this->col->offsetExists($offset);
165
    }
166
167
    public function offsetGet($offset)
168
    {
169
        $this->initialize();
170
        return $this->col->offsetGet($offset);
171
    }
172
173
    public function offsetSet($offset, $value)
174
    {
175
        $this->initialize();
176
        $this->changed = true;
177
        return $this->col->offsetSet($offset, $value);
178
    }
179
180
    public function offsetUnset($offset)
181
    {
182
        $this->initialize();
183
        $this->changed = true;
184
        return $this->col->offsetUnset($offset);
185
    }
186
187
    public function partition(\Closure $p)
188
    {
189
        $this->initialize();
190
        return $this->col->partition($p);
191
    }
192
193
    public function remove($key)
194
    {
195
        $this->initialize();
196
        $this->changed = true;
197
        return $this->col->remove($key);
198
    }
199
200
    public function removeElement($element)
201
    {
202
        $this->initialize();
203
        $this->changed = true;
204
        return $this->col->removeElement($element);
205
    }
206
207
    public function set($key, $value)
208
    {
209
        $this->initialize();
210
        $this->changed = true;
211
        return $this->col->set($key, $value);
212
    }
213
214
    public function slice($offset, $length = null)
215
    {
216
        $this->initialize();
217
        return $this->col->slice($offset, $length);
218
    }
219
220
    public function toArray()
221
    {
222
        $this->initialize();
223
        return $this->col->toArray();
224
    }
225
}
226