| 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: FixedList.php 418 2010-10-18 21:40:08Z jonathanhawk $ |
| 15 |
|
*/ |
| 16 |
|
namespace Xyster\Collection; |
| 17 |
|
/** |
| 18 |
|
* A list that cannot be changed |
| 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 FixedList extends FixedCollection implements IList |
| 26 |
|
{ |
| 27 |
|
/** |
| 28 |
|
* Creates a new fixed list |
| 29 |
|
* |
| 30 |
|
* @param IList $list |
| 31 |
|
*/ |
| 32 |
|
public function __construct( IList $list ) |
| 33 |
|
{ |
| 34 |
12 |
$this->_setDelegate($list); |
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
/** |
| 38 |
|
* Gets the value at a specified index |
| 39 |
|
* |
| 40 |
|
* This method is an alias to ArrayAccess::offsetGet |
| 41 |
|
* |
| 42 |
|
* The index must be greater than or equal to 0 and less than or equal to |
| 43 |
|
* the size of this collection. In other words, an index is valid if |
| 44 |
|
* <code>( $index < 0 || $index > count($list) )</code> is false. |
| 45 |
|
* |
| 46 |
|
* @param int $index The index to get |
| 47 |
|
* @return mixed The value found at $index |
| 48 |
|
* @throws OutOfBoundsException if the index is invalid |
| 49 |
|
*/ |
| 50 |
|
public function get( $index ) |
| 51 |
|
{ |
| 52 |
1 |
return $this->_getDelegate()->offsetGet($index); |
| 53 |
|
} |
| 54 |
|
|
| 55 |
|
/** |
| 56 |
|
* Returns the first index found for the specified value |
| 57 |
|
* |
| 58 |
|
* @param mixed $value |
| 59 |
|
* @return int The first index found, or null if the value isn't contained |
| 60 |
|
*/ |
| 61 |
|
public function indexOf( $value ) |
| 62 |
|
{ |
| 63 |
1 |
return $this->_getDelegate()->indexOf($value); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
/** |
| 67 |
|
* This list is unmodifiable, so this method will always throw an exception |
| 68 |
|
* |
| 69 |
|
* @param int $index The index at which to insert |
| 70 |
|
* @param mixed $value The value to insert |
| 71 |
|
* @throws UnmodifiableException Always |
| 72 |
|
*/ |
| 73 |
|
public function insert( $index, $value ) |
| 74 |
|
{ |
| 75 |
1 |
throw new UnmodifiableException("This collection cannot be changed"); |
| 76 |
|
} |
| 77 |
|
|
| 78 |
|
/** |
| 79 |
|
* This list is unmodifiable, so this method will always throw an exception |
| 80 |
|
* |
| 81 |
|
* @param int $index The index at which to insert |
| 82 |
|
* @param Xyster_Collection_Interface $values The value to insert |
| 83 |
|
* @throws UnmodifiableException Always |
| 84 |
|
*/ |
| 85 |
|
public function insertAll( $index, ICollection $values ) |
| 86 |
|
{ |
| 87 |
1 |
throw new UnmodifiableException("This collection cannot be changed"); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
/** |
| 91 |
|
* Gets whether the specified index exists in the list |
| 92 |
|
* |
| 93 |
|
* @param int $index The index to test |
| 94 |
|
* @return boolean Whether the index is in the list |
| 95 |
|
*/ |
| 96 |
|
public function offsetExists( $index ) |
| 97 |
|
{ |
| 98 |
1 |
return $this->_getDelegate()->offsetExists($index); |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
/** |
| 102 |
|
* Gets the value at a specified index |
| 103 |
|
* |
| 104 |
|
* The index must be greater than or equal to 0 and less than |
| 105 |
|
* the size of this collection. In other words, an index is valid if |
| 106 |
|
* <code>( $index < 0 || $index >= $this->count() )</code> is false. |
| 107 |
|
* |
| 108 |
|
* @param int $index The index to get |
| 109 |
|
* @return mixed The value found at $index |
| 110 |
|
* @throws OutOfBoundsException if the index is invalid |
| 111 |
|
*/ |
| 112 |
|
public function offsetGet( $index ) |
| 113 |
|
{ |
| 114 |
1 |
return $this->_getDelegate()->offsetGet($index); |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
/** |
| 118 |
|
* This list is unmodifiable, so this method will always throw an exception |
| 119 |
|
* |
| 120 |
|
* @param int $index The index to set |
| 121 |
|
* @param mixed $value The value to set |
| 122 |
|
* @throws UnmodifiableException Always |
| 123 |
|
*/ |
| 124 |
|
public function offsetSet( $index, $value ) |
| 125 |
|
{ |
| 126 |
1 |
throw new UnmodifiableException("This collection cannot be changed"); |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
/** |
| 130 |
|
* This list is unmodifiable, so this method will always throw an exception |
| 131 |
|
* |
| 132 |
|
* @param int $index The index to "unset" |
| 133 |
|
* @throws UnmodifiableException Always |
| 134 |
|
*/ |
| 135 |
|
public function offsetUnset( $index ) |
| 136 |
|
{ |
| 137 |
1 |
throw new UnmodifiableException("This collection cannot be changed"); |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
/** |
| 141 |
|
* This list is unmodifiable, so this method will always throw an exception |
| 142 |
|
* |
| 143 |
|
* @param int $index The index to "unset" |
| 144 |
|
* @return mixed The value removed |
| 145 |
|
* @throws UnmodifiableException Always |
| 146 |
|
*/ |
| 147 |
|
public function removeAt( $index ) |
| 148 |
|
{ |
| 149 |
1 |
throw new UnmodifiableException("This collection cannot be changed"); |
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
/** |
| 153 |
|
* This list is unmodifiable, so this method will always throw an exception |
| 154 |
|
* |
| 155 |
|
* @param int $index The index to set |
| 156 |
|
* @param mixed $value The value to set |
| 157 |
|
* @throws UnmodifiableException Always |
| 158 |
|
*/ |
| 159 |
|
public function set( $index, $value ) |
| 160 |
|
{ |
| 161 |
1 |
throw new UnmodifiableException("This collection cannot be changed"); |
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
/** |
| 165 |
|
* This list is unmodifiable, so this method will always throw an exception |
| 166 |
|
* |
| 167 |
|
* @param int $from The starting index |
| 168 |
|
* @param int $count The number of elements to remove |
| 169 |
|
* @throws UnmodifiableException Always |
| 170 |
|
*/ |
| 171 |
|
public function slice( $from, $count ) |
| 172 |
|
{ |
| 173 |
1 |
throw new UnmodifiableException("This collection cannot be changed"); |
| 174 |
|
} |
| 175 |
1 |
} |