Innmind /
Immutable
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | declare(strict_types = 1); |
||
| 3 | |||
| 4 | namespace Innmind\Immutable; |
||
| 5 | |||
| 6 | use Innmind\Immutable\Exception\InvalidArgumentException; |
||
| 7 | use Innmind\Immutable\Exception\BadMethodCallException; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @deprecated To be removed in 2.0 |
||
| 11 | */ |
||
| 12 | class TypedCollection extends Collection implements TypedCollectionInterface |
||
|
0 ignored issues
–
show
The interface
Innmind\Immutable\TypedCollectionInterface has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 13 | { |
||
| 14 | private $type; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Constructor |
||
| 18 | * |
||
| 19 | * @param string $type The class every element must respect |
||
| 20 | * @param array $values |
||
| 21 | */ |
||
| 22 | 71 | public function __construct($type, array $values) |
|
| 23 | { |
||
| 24 | 71 | $type = (string) $type; |
|
| 25 | 71 | $this->validate($type, $values); |
|
| 26 | |||
| 27 | 70 | $this->type = $type; |
|
| 28 | 70 | parent::__construct($values); |
|
| 29 | 70 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * {@inheritdoc} |
||
| 33 | */ |
||
| 34 | 61 | public function getType(): string |
|
| 35 | { |
||
| 36 | 61 | return $this->type; |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * {@inheritdoc} |
||
| 41 | */ |
||
| 42 | 1 | public function type(): string |
|
| 43 | { |
||
| 44 | 1 | return $this->type; |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * {@inheritdoc} |
||
| 49 | */ |
||
| 50 | 1 | public function filter(callable $filter = null): CollectionInterface |
|
| 51 | { |
||
| 52 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 53 | 1 | $this->type, |
|
| 54 | 1 | parent::filter($filter)->toPrimitive() |
|
| 55 | ); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * {@inheritdoc} |
||
| 60 | */ |
||
| 61 | 3 | public function intersect(CollectionInterface $collection): CollectionInterface |
|
| 62 | { |
||
| 63 | 3 | $this->validateCollection($collection); |
|
| 64 | |||
| 65 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 66 | 1 | $this->type, |
|
| 67 | 1 | parent::intersect($collection)->toPrimitive() |
|
| 68 | ); |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * {@inheritdoc} |
||
| 73 | */ |
||
| 74 | 1 | View Code Duplication | public function chunk(int $size): CollectionInterface |
| 75 | { |
||
| 76 | 1 | $chunks = parent::chunk($size); |
|
| 77 | 1 | $subs = []; |
|
| 78 | |||
| 79 | 1 | foreach ($chunks as $chunk) { |
|
| 80 | 1 | $subs[] = new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 81 | 1 | $this->type, |
|
| 82 | 1 | $chunk->toPrimitive() |
|
| 83 | ); |
||
| 84 | } |
||
| 85 | |||
| 86 | 1 | return new parent($subs); |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\Collection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * {@inheritdoc} |
||
| 91 | */ |
||
| 92 | 1 | public function shift(): CollectionInterface |
|
| 93 | { |
||
| 94 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 95 | 1 | $this->type, |
|
| 96 | 1 | parent::shift()->toPrimitive() |
|
| 97 | ); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * {@inheritdoc} |
||
| 102 | */ |
||
| 103 | 1 | public function uintersect(CollectionInterface $collection, callable $intersecter): CollectionInterface |
|
| 104 | { |
||
| 105 | 1 | $this->validateCollection($collection); |
|
| 106 | |||
| 107 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 108 | 1 | $this->type, |
|
| 109 | 1 | parent::uintersect($collection, $intersecter)->toPrimitive() |
|
| 110 | ); |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * {@inheritdoc} |
||
| 115 | */ |
||
| 116 | 2 | public function keyIntersect(CollectionInterface $collection): CollectionInterface |
|
| 117 | { |
||
| 118 | 2 | $this->validateCollection($collection); |
|
| 119 | |||
| 120 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 121 | 1 | $this->type, |
|
| 122 | 1 | parent::keyIntersect($collection)->toPrimitive() |
|
| 123 | ); |
||
| 124 | } |
||
| 125 | |||
| 126 | /** |
||
| 127 | * {@inheritdoc} |
||
| 128 | */ |
||
| 129 | 2 | public function map(callable $mapper): CollectionInterface |
|
| 130 | { |
||
| 131 | 2 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 132 | 2 | $this->type, |
|
| 133 | 2 | parent::map($mapper)->toPrimitive() |
|
| 134 | ); |
||
| 135 | } |
||
| 136 | |||
| 137 | /** |
||
| 138 | * {@inheritdoc} |
||
| 139 | */ |
||
| 140 | 2 | View Code Duplication | public function pad(int $size, $value): CollectionInterface |
| 141 | { |
||
| 142 | 2 | $this->validate($this->type, [$value]); |
|
| 143 | |||
| 144 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 145 | 1 | $this->type, |
|
| 146 | 1 | parent::pad($size, $value)->toPrimitive() |
|
| 147 | ); |
||
| 148 | } |
||
| 149 | |||
| 150 | /** |
||
| 151 | * {@inheritdoc} |
||
| 152 | */ |
||
| 153 | 1 | public function pop(): CollectionInterface |
|
| 154 | { |
||
| 155 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 156 | 1 | $this->type, |
|
| 157 | 1 | parent::pop()->toPrimitive() |
|
| 158 | ); |
||
| 159 | } |
||
| 160 | |||
| 161 | /** |
||
| 162 | * {@inheritdoc} |
||
| 163 | */ |
||
| 164 | 2 | public function diff(CollectionInterface $collection): CollectionInterface |
|
| 165 | { |
||
| 166 | 2 | $this->validateCollection($collection); |
|
| 167 | |||
| 168 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 169 | 1 | $this->type, |
|
| 170 | 1 | parent::diff($collection)->toPrimitive() |
|
| 171 | ); |
||
| 172 | } |
||
| 173 | |||
| 174 | /** |
||
| 175 | * {@inheritdoc} |
||
| 176 | */ |
||
| 177 | 2 | View Code Duplication | public function push($value): CollectionInterface |
| 178 | { |
||
| 179 | 2 | $this->validate($this->type, [$value]); |
|
| 180 | |||
| 181 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 182 | 1 | $this->type, |
|
| 183 | 1 | parent::push($value)->toPrimitive() |
|
| 184 | ); |
||
| 185 | } |
||
| 186 | |||
| 187 | /** |
||
| 188 | * {@inheritdoc} |
||
| 189 | */ |
||
| 190 | 2 | public function rand(int $num = 1): CollectionInterface |
|
| 191 | { |
||
| 192 | 2 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 193 | 2 | $this->type, |
|
| 194 | 2 | parent::rand($num)->toPrimitive() |
|
| 195 | ); |
||
| 196 | } |
||
| 197 | |||
| 198 | /** |
||
| 199 | * {@inheritdoc} |
||
| 200 | */ |
||
| 201 | 2 | public function merge(CollectionInterface $collection): CollectionInterface |
|
| 202 | { |
||
| 203 | 2 | $this->validateCollection($collection); |
|
| 204 | |||
| 205 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 206 | 1 | $this->type, |
|
| 207 | 1 | parent::merge($collection)->toPrimitive() |
|
| 208 | ); |
||
| 209 | } |
||
| 210 | |||
| 211 | /** |
||
| 212 | * {@inheritdoc} |
||
| 213 | */ |
||
| 214 | 1 | public function slice(int $offset, int $length = null, bool $preserveKeys = false): CollectionInterface |
|
| 215 | { |
||
| 216 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 217 | 1 | $this->type, |
|
| 218 | 1 | parent::slice($offset, $length, $preserveKeys)->toPrimitive() |
|
| 219 | ); |
||
| 220 | } |
||
| 221 | |||
| 222 | /** |
||
| 223 | * {@inheritdoc} |
||
| 224 | */ |
||
| 225 | 2 | public function udiff(CollectionInterface $collection, callable $differ): CollectionInterface |
|
| 226 | { |
||
| 227 | 2 | $this->validateCollection($collection); |
|
| 228 | |||
| 229 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 230 | 1 | $this->type, |
|
| 231 | 1 | parent::udiff($collection, $differ)->toPrimitive() |
|
| 232 | ); |
||
| 233 | } |
||
| 234 | |||
| 235 | /** |
||
| 236 | * {@inheritdoc} |
||
| 237 | */ |
||
| 238 | 1 | public function splice(int $offset, int $length = 0, $replacement = []): CollectionInterface |
|
| 239 | { |
||
| 240 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 241 | 1 | $this->type, |
|
| 242 | 1 | parent::splice($offset, $length, $replacement)->toPrimitive() |
|
| 243 | ); |
||
| 244 | } |
||
| 245 | |||
| 246 | /** |
||
| 247 | * {@inheritdoc} |
||
| 248 | */ |
||
| 249 | 1 | public function unique(int $flags = self::SORT_REGULAR): CollectionInterface |
|
| 250 | { |
||
| 251 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 252 | 1 | $this->type, |
|
| 253 | 1 | parent::unique($flags)->toPrimitive() |
|
| 254 | ); |
||
| 255 | } |
||
| 256 | |||
| 257 | /** |
||
| 258 | * {@inheritdoc} |
||
| 259 | */ |
||
| 260 | 1 | public function values(): CollectionInterface |
|
| 261 | { |
||
| 262 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 263 | 1 | $this->type, |
|
| 264 | 1 | parent::values()->toPrimitive() |
|
| 265 | ); |
||
| 266 | } |
||
| 267 | |||
| 268 | /** |
||
| 269 | * {@inheritdoc} |
||
| 270 | */ |
||
| 271 | 2 | public function replace(CollectionInterface $collection): CollectionInterface |
|
| 272 | { |
||
| 273 | 2 | $this->validateCollection($collection); |
|
| 274 | |||
| 275 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 276 | 1 | $this->type, |
|
| 277 | 1 | parent::replace($collection)->toPrimitive() |
|
| 278 | ); |
||
| 279 | } |
||
| 280 | |||
| 281 | /** |
||
| 282 | * {@inheritdoc} |
||
| 283 | */ |
||
| 284 | 1 | public function reverse(bool $preserveKeys = false): CollectionInterface |
|
| 285 | { |
||
| 286 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 287 | 1 | $this->type, |
|
| 288 | 1 | parent::reverse($preserveKeys)->toPrimitive() |
|
| 289 | ); |
||
| 290 | } |
||
| 291 | |||
| 292 | /** |
||
| 293 | * {@inheritdoc} |
||
| 294 | */ |
||
| 295 | 2 | View Code Duplication | public function unshift($value): CollectionInterface |
| 296 | { |
||
| 297 | 2 | $this->validate($this->type, [$value]); |
|
| 298 | |||
| 299 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 300 | 1 | $this->type, |
|
| 301 | 1 | parent::unshift($value)->toPrimitive() |
|
| 302 | ); |
||
| 303 | } |
||
| 304 | |||
| 305 | /** |
||
| 306 | * {@inheritdoc} |
||
| 307 | */ |
||
| 308 | 2 | public function keyDiff(CollectionInterface $collection): CollectionInterface |
|
| 309 | { |
||
| 310 | 2 | $this->validateCollection($collection); |
|
| 311 | |||
| 312 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 313 | 1 | $this->type, |
|
| 314 | 1 | parent::keyDiff($collection)->toPrimitive() |
|
| 315 | ); |
||
| 316 | } |
||
| 317 | |||
| 318 | /** |
||
| 319 | * {@inheritdoc} |
||
| 320 | */ |
||
| 321 | 2 | public function ukeyDiff(CollectionInterface $collection, callable $differ): CollectionInterface |
|
| 322 | { |
||
| 323 | 2 | $this->validateCollection($collection); |
|
| 324 | |||
| 325 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 326 | 1 | $this->type, |
|
| 327 | 1 | parent::ukeyDiff($collection, $differ)->toPrimitive() |
|
| 328 | ); |
||
| 329 | } |
||
| 330 | |||
| 331 | /** |
||
| 332 | * {@inheritdoc} |
||
| 333 | */ |
||
| 334 | 2 | public function associativeDiff(CollectionInterface $collection): CollectionInterface |
|
| 335 | { |
||
| 336 | 2 | $this->validateCollection($collection); |
|
| 337 | |||
| 338 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 339 | 1 | $this->type, |
|
| 340 | 1 | parent::associativeDiff($collection)->toPrimitive() |
|
| 341 | ); |
||
| 342 | } |
||
| 343 | |||
| 344 | /** |
||
| 345 | * {@inheritdoc} |
||
| 346 | */ |
||
| 347 | 2 | public function ukeyIntersect(CollectionInterface $collection, callable $intersecter): CollectionInterface |
|
| 348 | { |
||
| 349 | 2 | $this->validateCollection($collection); |
|
| 350 | |||
| 351 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 352 | 1 | $this->type, |
|
| 353 | 1 | parent::ukeyIntersect($collection, $intersecter)->toPrimitive() |
|
| 354 | ); |
||
| 355 | } |
||
| 356 | |||
| 357 | /** |
||
| 358 | * {@inheritdoc} |
||
| 359 | */ |
||
| 360 | 2 | public function associativeIntersect(CollectionInterface $collection): CollectionInterface |
|
| 361 | { |
||
| 362 | 2 | $this->validateCollection($collection); |
|
| 363 | |||
| 364 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 365 | 1 | $this->type, |
|
| 366 | 1 | parent::associativeIntersect($collection)->toPrimitive() |
|
| 367 | ); |
||
| 368 | } |
||
| 369 | |||
| 370 | /** |
||
| 371 | * {@inheritdoc} |
||
| 372 | */ |
||
| 373 | 1 | public function sort(int $flags = self::SORT_REGULAR): CollectionInterface |
|
| 374 | { |
||
| 375 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 376 | 1 | $this->type, |
|
| 377 | 1 | parent::sort($flags)->toPrimitive() |
|
| 378 | ); |
||
| 379 | } |
||
| 380 | |||
| 381 | /** |
||
| 382 | * {@inheritdoc} |
||
| 383 | */ |
||
| 384 | 1 | public function associativeSort(int $flags = self::SORT_REGULAR): CollectionInterface |
|
| 385 | { |
||
| 386 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 387 | 1 | $this->type, |
|
| 388 | 1 | parent::associativeSort($flags)->toPrimitive() |
|
| 389 | ); |
||
| 390 | } |
||
| 391 | |||
| 392 | /** |
||
| 393 | * {@inheritdoc} |
||
| 394 | */ |
||
| 395 | 1 | public function keySort(int $flags = self::SORT_REGULAR): CollectionInterface |
|
| 396 | { |
||
| 397 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 398 | 1 | $this->type, |
|
| 399 | 1 | parent::keySort($flags)->toPrimitive() |
|
| 400 | ); |
||
| 401 | } |
||
| 402 | |||
| 403 | /** |
||
| 404 | * {@inheritdoc} |
||
| 405 | */ |
||
| 406 | 1 | public function ukeySort(callable $sorter): CollectionInterface |
|
| 407 | { |
||
| 408 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 409 | 1 | $this->type, |
|
| 410 | 1 | parent::ukeySort($sorter)->toPrimitive() |
|
| 411 | ); |
||
| 412 | } |
||
| 413 | |||
| 414 | /** |
||
| 415 | * {@inheritdoc} |
||
| 416 | */ |
||
| 417 | 1 | public function reverseSort(int $flags = self::SORT_REGULAR): CollectionInterface |
|
| 418 | { |
||
| 419 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 420 | 1 | $this->type, |
|
| 421 | 1 | parent::reverseSort($flags)->toPrimitive() |
|
| 422 | ); |
||
| 423 | } |
||
| 424 | |||
| 425 | /** |
||
| 426 | * {@inheritdoc} |
||
| 427 | */ |
||
| 428 | 1 | public function usort(callable $sorter): CollectionInterface |
|
| 429 | { |
||
| 430 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 431 | 1 | $this->type, |
|
| 432 | 1 | parent::usort($sorter)->toPrimitive() |
|
| 433 | ); |
||
| 434 | } |
||
| 435 | |||
| 436 | /** |
||
| 437 | * {@inheritdoc} |
||
| 438 | */ |
||
| 439 | 1 | public function associativeReverseSort(int $flags = self::SORT_REGULAR): CollectionInterface |
|
| 440 | { |
||
| 441 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 442 | 1 | $this->type, |
|
| 443 | 1 | parent::associativeReverseSort($flags)->toPrimitive() |
|
| 444 | ); |
||
| 445 | } |
||
| 446 | |||
| 447 | /** |
||
| 448 | * {@inheritdoc} |
||
| 449 | */ |
||
| 450 | 1 | public function keyReverseSort(int $flags = self::SORT_REGULAR): CollectionInterface |
|
| 451 | { |
||
| 452 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 453 | 1 | $this->type, |
|
| 454 | 1 | parent::keyReverseSort($flags)->toPrimitive() |
|
| 455 | ); |
||
| 456 | } |
||
| 457 | |||
| 458 | /** |
||
| 459 | * {@inheritdoc} |
||
| 460 | */ |
||
| 461 | 1 | public function uassociativeSort(callable $sorter): CollectionInterface |
|
| 462 | { |
||
| 463 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 464 | 1 | $this->type, |
|
| 465 | 1 | parent::uassociativeSort($sorter)->toPrimitive() |
|
| 466 | ); |
||
| 467 | } |
||
| 468 | |||
| 469 | /** |
||
| 470 | * {@inheritdoc} |
||
| 471 | */ |
||
| 472 | 1 | public function naturalSort(): CollectionInterface |
|
| 473 | { |
||
| 474 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 475 | 1 | $this->type, |
|
| 476 | 1 | parent::naturalSort()->toPrimitive() |
|
| 477 | ); |
||
| 478 | } |
||
| 479 | |||
| 480 | /** |
||
| 481 | * {@inheritdoc} |
||
| 482 | */ |
||
| 483 | 1 | public function shuffle(): CollectionInterface |
|
| 484 | { |
||
| 485 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 486 | 1 | $this->type, |
|
| 487 | 1 | parent::shuffle()->toPrimitive() |
|
| 488 | ); |
||
| 489 | } |
||
| 490 | |||
| 491 | /** |
||
| 492 | * {@inheritdoc} |
||
| 493 | */ |
||
| 494 | 1 | public function take(int $size, bool $preserveKeys = false): CollectionInterface |
|
| 495 | { |
||
| 496 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 497 | 1 | $this->type, |
|
| 498 | 1 | parent::take($size, $preserveKeys)->toPrimitive() |
|
| 499 | ); |
||
| 500 | } |
||
| 501 | |||
| 502 | /** |
||
| 503 | * {@inheritdoc} |
||
| 504 | */ |
||
| 505 | 1 | public function grep(string $pattern, bool $revert = false): CollectionInterface |
|
| 506 | { |
||
| 507 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 508 | 1 | $this->type, |
|
| 509 | 1 | parent::grep($pattern, $revert)->toPrimitive() |
|
| 510 | ); |
||
| 511 | } |
||
| 512 | |||
| 513 | /** |
||
| 514 | * {@inheritdoc} |
||
| 515 | */ |
||
| 516 | 2 | View Code Duplication | public function set($key, $value): CollectionInterface |
| 517 | { |
||
| 518 | 2 | $this->validate($this->type, [$value]); |
|
| 519 | |||
| 520 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 521 | 1 | $this->type, |
|
| 522 | 1 | parent::set($key, $value)->toPrimitive() |
|
| 523 | ); |
||
| 524 | } |
||
| 525 | |||
| 526 | /** |
||
| 527 | * {@inheritdoc} |
||
| 528 | */ |
||
| 529 | 1 | public function contains($value): bool |
|
| 530 | { |
||
| 531 | //avoid searching the collection if we know it's not of the same type |
||
| 532 | try { |
||
| 533 | 1 | $this->validate($this->type, [$value]); |
|
| 534 | 1 | } catch (InvalidArgumentException $e) { |
|
| 535 | 1 | return false; |
|
| 536 | } |
||
| 537 | |||
| 538 | 1 | return parent::contains($value); |
|
| 539 | } |
||
| 540 | |||
| 541 | /** |
||
| 542 | * {@inheritdoc} |
||
| 543 | */ |
||
| 544 | 1 | public function walk(callable $walker): CollectionInterface |
|
| 545 | { |
||
| 546 | 1 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 547 | 1 | $this->type, |
|
| 548 | 1 | parent::walk($walker)->toPrimitive() |
|
| 549 | ); |
||
| 550 | } |
||
| 551 | |||
| 552 | /** |
||
| 553 | * {@inheritdoc} |
||
| 554 | */ |
||
| 555 | 2 | public function unset($index): CollectionInterface |
|
| 556 | { |
||
| 557 | 2 | return new self( |
|
|
0 ignored issues
–
show
The class
Innmind\Immutable\TypedCollection has been deprecated with message: To be removed in 2.0
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 558 | 2 | $this->type, |
|
| 559 | 2 | parent::unset($index)->toPrimitive() |
|
| 560 | ); |
||
| 561 | } |
||
| 562 | |||
| 563 | /** |
||
| 564 | * Check if every element respect the given type |
||
| 565 | * |
||
| 566 | * @throws InvalidArgumentException If a value doesn't respect the type |
||
| 567 | * |
||
| 568 | * @param string $type |
||
| 569 | * @param array $values |
||
| 570 | * |
||
| 571 | * @return void |
||
| 572 | */ |
||
| 573 | 71 | protected function validate(string $type, array $values) |
|
| 574 | { |
||
| 575 | 71 | foreach ($values as $value) { |
|
| 576 | 57 | if (!$value instanceof $type) { |
|
| 577 | 6 | throw new InvalidArgumentException(sprintf( |
|
| 578 | 57 | 'Each value must be an instance of "%s"', |
|
| 579 | $type |
||
| 580 | )); |
||
| 581 | } |
||
| 582 | } |
||
| 583 | 70 | } |
|
| 584 | |||
| 585 | /** |
||
| 586 | * Check if the given collection is compatible with the current one |
||
| 587 | * |
||
| 588 | * @throws BadMethodCallException If the collection is not compatible |
||
| 589 | * |
||
| 590 | * @param CollectionInterface $collection |
||
| 591 | * |
||
| 592 | * @return void |
||
| 593 | */ |
||
| 594 | 24 | private function validateCollection(CollectionInterface $collection) |
|
| 595 | { |
||
| 596 | if ( |
||
| 597 | 24 | !$collection instanceof self || |
|
| 598 | 24 | $collection->getType() !== $this->type |
|
| 599 | ) { |
||
| 600 | 12 | throw new BadMethodCallException( |
|
| 601 | 12 | 'The given collection is not compatible' |
|
| 602 | ); |
||
| 603 | } |
||
| 604 | 12 | } |
|
| 605 | } |
||
| 606 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.