http://phing.info/

Source Code Coverage

Designed for use with PHPUnit2, Xdebug and Phing.

Methods: 25 LOC: 341 Statements: 29

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


Report generated at 2008-03-05T18:27:43-05:00