http://phing.info/

Source Code Coverage

Designed for use with PHPUnit2, Xdebug and Phing.

Methods: 22 LOC: 296 Statements: 24
Legend: executednot executeddead code
Source file Statements Methods Total coverage
DelegateMap.php 91.7% 90.9% 91.3%
   
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
 * @version   $Id: DelegateMap.php 418 2010-10-18 21:40:08Z jonathanhawk $
15
 */
16
namespace Xyster\Collection;
17
/**
18
 * A delegate for maps
19
 *
20
 * @category  Xyster
21
 * @package   Xyster_Collection
22
 * @copyright Copyright LibreWorks, LLC (http://libreworks.net)
23
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
24
 */
25
class DelegateMap implements IMap
26
{
27
    /**
28
     * @var IMap
29
     */
30
    private $_delegate;
31
32
    /**
33
     * Creates a new delegate collection
34
     *
35
     * @param IMap $delegate
36
     */
37
    public function __construct( IMap $delegate )
38
    {
39 26
        $this->_delegate = $delegate;
40
    }
41
42
    /**
43
     * Removes all items from the collection
44
     *
45
     * @throws UnmodifiableException if the collection cannot be modified
46
     */
47
    public function clear()
48
    {
49 1
        $this->_delegate->clear();
50
    }
51
52
    /**
53
     * Gets the number of items in the collection
54
     *
55
     * @return int The number of items
56
     */
57
    public function count()
58
    {
59 2
        return $this->_delegate->count();
60
    }
61
62
    /**
63
     * Tests to see whether the map contains the key supplied
64
     *
65
     * If the supplied value is an object, and the map allows objects as keys,
66
     * the comparison will be done for identity (===) and not for value (==).
67
     *
68
     * This method is an alias to ArrayAccess::offsetExists
69
     *
70
     * @param mixed $key The key to test
71
     * @return boolean Whether the map contains the supplied key
72
     */
73
    public function containsKey( $key )
74
    {
75 1
        return $this->_delegate->offsetExists($key);
76
    }
77
78
    /**
79
     * Tests to see whether the map contains the value supplied
80
     *
81
     * If the supplied value is an object, the comparison will be done for
82
     * identity (===) and not for value (==).
83
     *
84
     * @param mixed $item The item to test
85
     * @return boolean Whether the map contains the supplied value
86
     */
87
    public function containsValue( $item )
88
    {
89 1
        return $this->_delegate->containsValue($item);
90
    }
91
92
    /**
93
     * Gets the value corresponding to the supplied key
94
     *
95
     * This method could return null if the value is null, or if the value was
96
     * not found.  Use {@link containsValue} to check which is true.
97
     *
98
     * @param mixed $key
99
     * @return mixed The value found, or null if none
100
     */
101
    public function get( $key )
102
    {
103 1
        return $this->_delegate->get($key);
104
    }
105
106
    /**
107
     * Gets an iterator for the values in the collection
108
     *
109
     * @return \SeekableIterator
110
     */
111
    public function getIterator()
112
    {
113 1
        return $this->_delegate->getIterator();
114
    }
115
116
    /**
117
     * Gets all keys contained in this map
118
     *
119
     * @return ISet The keys in this map
120
     */
121
    public function keys()
122
    {
123 1
        return $this->_delegate->keys();
124
    }
125
126
    /**
127
     * Gets the first key found for the value supplied
128
     *
129
     * This method could return null if the key is null, or if the key was not
130
     * found.  Use {@link containsKey} to check which is true.
131
     *
132
     * @param mixed $value
133
     * @return mixed The key found, or null if none
134
     */
135
    public function keyFor( $value )
136
    {
137 1
        return $this->_delegate->keyFor($value);
138
    }
139
140
    /**
141
     * Gets all keys for the value supplied
142
     *
143
     * @param mixed $value The value for which to search
144
     * @return ISet
145
     */
146
    public function keysFor( $value )
147
    {
148 1
        return $this->_delegate->keysFor($value);
149
    }
150
151
    /**
152
     * Tests to see if the collection contains no elements
153
     *
154
     * The return value from this method should be equivalent to
155
     * <code>( $collection->count() == 0 )</code>.
156
     *
157
     * @return boolean Whether this collection has no elements
158
     */
159
    public function isEmpty()
160
    {
161 1
        return $this->_delegate->isEmpty();
162
    }
163
164
    /**
165
     * Combines this map with the supplied map
166
     *
167
     * The values in the supplied map will take precedence if this map and the
168
     * supplied map have duplicate keys.
169
     *
170
     * @param IMap $map
171
     * @throws UnmodifiableException If the map cannot be modified
172
     * @throws InvalidArgumentException if any of the keys or values are invalid for this map
173
     * @return boolean Whether the map changed as a result of this method
174
     */
175
    public function merge( IMap $map )
176
    {
177 1
        return $this->_delegate->merge($map);
178
    }
179
180
    /**
181
     * Gets whether the specified key exists in the map
182
     *
183
     * @param object $key The key to test
184
     * @return boolean Whether the key is in the map
185
     * @throws UnmodifiableException if the key type is incorrect
186
     */
187
    public function offsetExists( $key )
188
    {
189 1
        return $this->_delegate->offsetExists($key);
190
    }
191
192
    /**
193
     * Gets the value at a specified key
194
     *
195
     * @param object $key The index to get
196
     * @return mixed The value found at $key or null if none
197
     */
198
    public function offsetGet( $key )
199
    {
200 1
        return $this->_delegate->offsetGet($key);
201
    }
202
203
    /**
204
     * Sets the value at a given key.
205
     *
206
     * @param object $key The key to set
207
     * @param mixed $value The value to set
208
     * @throws UnmodifiableException if the collection cannot be modified
209
     */
210
    public function offsetSet( $key, $value )
211
    {
212 1
        $this->_delegate->offsetSet($key, $value);
213
    }
214
215
    /**
216
     * Removes a value at the specified key
217
     *
218
     * @param object $key The key to "unset"
219
     * @throws UnmodifiableException if the collection cannot be modified
220
     */
221
    public function offsetUnset( $key )
222
    {
223 1
        $this->_delegate->offsetUnset($key);
224
    }
225
226
    /**
227
     * Removes the mapping for the specified key
228
     *
229
     * This method is an alias to ArrayAccess::offsetUnset
230
     *
231
     * @param mixed $key
232
     * @throws UnmodifiableException If the map cannot be modified
233
     */
234
    public function remove( $key )
235
    {
236 1
        $this->_delegate->offsetUnset($key);
237
    }
238
239
    /**
240
     * Sets a mapping for the key and value supplied
241
     *
242
     * This method is an alias to ArrayAccess::offsetSet
243
     *
244
     * @param mixed $key
245
     * @param mixed $value
246
     * @throws UnmodifiableException If the map cannot be modified
247
     */
248
    public function set( $key, $value )
249
    {
250 1
        $this->_delegate->offsetSet($key, $value);
251
    }
252
253
    /**
254
     * Puts the items in this collection into an array
255
     *
256
     * For Maps that allow for scalar-only keys, this array should have the map
257
     * keys as keys and values as values.  If the map allows complex types as
258
     * keys, this array should contain objects with the key and value available.
259
     *
260
     * @return array The items in this collection
261
     */
262
    public function toArray()
263
    {
264 1
        return $this->_delegate->toArray();
265
    }
266
267
    /**
268
     * Gets the values contained in this map
269
     *
270
     * @return Xyster_Collection_Interface
271
     */
272
    public function values()
273
    {
274 1
        return $this->_delegate->values();
275
    }
276
277
    /**
278
     * Gets the delegate map
279
     *
280
     * @return IMap
281
     */
282
    protected function _getDelegate()
283
    {
284
        return $this->_delegate;
285
    }
286
287
    /**
288
     * Sets the delegate map
289
     *
290
     * @param IMap $map
291
     */
292
    protected function _setDelegate( IMap $map )
293
    {
294
        $this->_delegate = $map;
295
    }
296 1
}


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