http://phing.info/

Source Code Coverage

Designed for use with PHPUnit2, Xdebug and Phing.

Methods: 24 LOC: 325 Statements: 25
Legend: executednot executeddead code
Source file Statements Methods Total coverage
EmptyList.php 100.0% 100.0% 100.0%
 
1
<?php
2
/**
3
 * Xyster Framework
4
 *
5
 * This source file is subject to the new BSD license that is bundled
6
 * with this package in the file LICENSE.txt.
7
 * It is also available through the world-wide-web at this URL:
8
 * http://www.opensource.org/licenses/bsd-license.php
9
 *
10
 * @category  Xyster
11
 * @package   Xyster_Collection
12
 * @copyright Copyright LibreWorks, LLC (http://libreworks.net)
13
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
14
 */
15
namespace Xyster\Collection;
16
/**
17
 * An immutable empty list
18
 *
19
 * @category  Xyster
20
 * @package   Xyster_Collection
21
 * @copyright Copyright LibreWorks, LLC (http://libreworks.net)
22
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
23
 */
24
class EmptyList implements IList
25
{
26
    /**
27
     * Adds an item to the collection
28
     *
29
     * @param mixed $item The item to add
30
     * @return boolean Whether the collection changed as a result of this method
31
     * @throws UnmodifiableException Always
32
     */
33
    public function add( $item )
34
    {
35 1
        throw new UnmodifiableException('This list is immutable');
36
    }
37
38
    /**
39
     * Removes all items from the collection
40
     *
41
     * @throws UnmodifiableException Always
42
     */
43
    public function clear()
44
    {
45 1
        throw new UnmodifiableException('This list is immutable');
46
    }
47
48
    /**
49
     * Tests to see whether the collection contains the value supplied
50
     *
51
     * @param mixed $item The item to test
52
     * @return boolean Whether the collection contains the supplied value
53
     */
54
    public function contains( $item )
55
    {
56 1
    	return false;
57
    }
58
59
    /**
60
     * Tests to see whether the collection contains all of the supplied values
61
     *
62
     * @param ICollection $values The values to test
63
     * @return boolean Whether the collection contains all of the supplied values
64
     */
65
    public function containsAll( ICollection $values )
66
    {
67 1
    	return false;
68
    }
69
70
    /**
71
     * Tests to see whether the collection contains any of the supplied values
72
     *
73
     * Basically, implementations can safely return true on the first item that
74
     * is found.
75
     *
76
     * @param ICollection $values The values to test
77
     * @return boolean Whether the collection contains any of the supplied values
78
     */
79
    public function containsAny( ICollection $values )
80
    {
81 1
    	return false;
82
    }
83
84
    /**
85
     * Gets the number of items in the collection
86
     *
87
     * @return int The number of items
88
     */
89
    public function count()
90
    {
91 1
    	return 0;
92
    }
93
94
    /**
95
     * Gets the value at a specified index
96
     *
97
     * This method is an alias to ArrayAccess::offsetGet
98
     *
99
     * @param int $index The index to get
100
     * @return mixed The value found at $index
101
     */
102
    public function get( $index )
103
    {
104 1
        throw new UnmodifiableException("Invalid index given");
105
    }
106
107
    /**
108
     * Gets an iterator for the values in the collection
109
     *
110
     * @return Iterator
111
     */
112
    public function getIterator()
113
    {
114 1
        return new \EmptyIterator;
115
    }
116
117
    /**
118
     * Returns the first index found for the specified value
119
     *
120
     * @param mixed $value
121
     * @return int The first index found, or null if the value isn't contained
122
     */
123
    public function indexOf( $value )
124
    {
125 1
    	return null;
126
    }
127
128
    /**
129
     * Inserts a value into the list at the specified index
130
     *
131
     * @param int $index The index at which to insert
132
     * @param mixed $value The value to insert
133
     * @throws UnmodifiableException Always
134
     */
135
    public function insert( $index, $value )
136
    {
137 1
        throw new UnmodifiableException('This list is immutable');
138
    }
139
140
    /**
141
     * Inserts the supplied values into the list at the specified index
142
     *
143
     * The index must be greater than or equal to 0 and less than or equal to
144
     * the size of this collection.  In other words, an index is valid if
145
     * <code>( $index < 0 || $index > count($list) )</code> is false.
146
     *
147
     * @param int $index The index at which to insert
148
     * @param ICollection $values The value to insert
149
     * @throws UnmodifiableException Always
150
     */
151
    public function insertAll( $index, ICollection $values )
152
    {
153 1
        throw new UnmodifiableException('This list is immutable');
154
    }
155
156
    /**
157
     * Tests to see if the collection contains no elements
158
     *
159
     * The return value from this method should be equivalent to
160
     * <code>( $collection->count() == 0 )</code>.
161
     *
162
     * @return boolean Whether this collection has no elements
163
     */
164
    public function isEmpty()
165
    {
166 1
        return true;
167
    }
168
169
    /**
170
     * Merges the values from the supplied collection into this one
171
     *
172
     * @param ICollection $values
173
     * @return boolean Whether the collection changed as a result of this method
174
     * @throws UnmodifiableException Always
175
     */
176
    public function merge( ICollection $values )
177
    {
178 1
        throw new UnmodifiableException('This list is immutable');
179
    }
180
181
    /**
182
     * Gets whether the specified index exists in the list
183
     *
184
     * @param int $index The index to test
185
     * @return boolean Whether the index is in the list
186
     */
187
    public function offsetExists( $index )
188
    {
189 1
        return false;
190
    }
191
192
    /**
193
     * Gets the value at a specified index
194
     *
195
     * @param int $index The index to get
196
     * @return mixed The value found at $index
197
     * @throws UnmodifiableException if the index is invalid
198
     */
199
    public function offsetGet( $index )
200
    {
201 1
        throw new UnmodifiableException("Invalid index given");
202
    }
203
204
    /**
205
     * Sets the value at a given index.
206
     *
207
     * The index must be greater than or equal to 0 and less than or equal to
208
     * the size of this collection.  In other words, an index is valid if
209
     * <code>( $index < 0 || $index > $this->count() )</code> is false.
210
     *
211
     * @param int $index The index to set
212
     * @param mixed $value The value to set
213
     * @throws OutOfBoundsException if the index is invalid
214
     */
215
    public function offsetSet( $index, $value )
216
    {
217 1
        throw new UnmodifiableException('This list is immutable');
218
    }
219
220
    /**
221
     * Removes a value at the specified index
222
     *
223
     * The index must be greater than or equal to 0 and less than
224
     * the size of this collection.  In other words, an index is valid if
225
     * <code>( $index < 0 || $index > $this->count() )</code> is false.
226
     *
227
     * @param int $index The index to "unset"
228
     */
229
    public function offsetUnset( $index )
230
    {
231 1
        throw new UnmodifiableException('This list is immutable');
232
    }
233
234
    /**
235
     * Removes the specified value from the collection
236
     *
237
     * @param mixed $item The value to remove
238
     * @return boolean If the value was in the collection
239
     * @throws UnmodifiableException Always
240
     */
241
    public function remove( $item )
242
    {
243 1
        throw new UnmodifiableException('This list is immutable');
244
    }
245
246
    /**
247
     * Removes all of the specified values from the collection
248
     *
249
     * @param ICollection $values The values to remove
250
     * @return boolean Whether the collection changed as a result of this method
251
     * @throws UnmodifiableException Always
252
     */
253
    public function removeAll( ICollection $values )
254
    {
255 1
        throw new UnmodifiableException('This list is immutable');
256
    }
257
258
    /**
259
     * Removes a value at the specified index
260
     *
261
     * This method is an alias to ArrayAccess::offsetUnset
262
     *
263
     * @param int $index The index to "unset"
264
     * @throws UnmodifiableException Always
265
     */
266
    public function removeAt( $index )
267
    {
268 1
        throw new UnmodifiableException('This list is immutable');
269
    }
270
271
    /**
272
     * Removes all values from the collection except for the ones specified
273
     *
274
     * If the collection doesn't contain any of the values supplied, it should
275
     * simply be emptied.
276
     *
277
     * @param ICollection $values The values to keep
278
     * @return boolean Whether the collection changed as a result of this method
279
     * @throws UnmodifiableException Always
280
     */
281
    public function retainAll( ICollection $values )
282
    {
283 1
        throw new UnmodifiableException('This list is immutable');
284
    }
285
286
    /**
287
     * Sets the value at a given index.
288
     *
289
     * This method is an alias to ArrayAccess::offsetSet.
290
     *
291
     * The index must be greater than or equal to 0 and less than or equal to
292
     * the size of this collection.  In other words, an index is valid if
293
     * <code>( $index < 0 || $index > count($list) )</code> is false.
294
     *
295
     * @param int $index The index to set
296
     * @param mixed $value The value to set
297
     * @throws UnmodifiableException Always
298
     */
299
    public function set( $index, $value )
300
    {
301 1
        throw new UnmodifiableException('This list is immutable');
302
    }
303
304
    /**
305
     * Removes all elements between $from and $to, including $from.
306
     *
307
     * @param int $from The starting index
308
     * @param int $to The index to end before reaching
309
     * @throws UnmodifiableException Always
310
     */
311
    public function slice( $from, $to )
312
    {
313 1
        throw new UnmodifiableException('This list is immutable');
314
    }
315
316
    /**
317
     * Puts the items in this collection into an array
318
     *
319
     * @return array The items in this collection
320
     */
321
    public function toArray()
322
    {
323 1
        return array();
324
    }
325
}


Report generated at 2010-10-18T17:19:49-04:00