|
|
|
@ -7,6 +7,7 @@ use Closure;
|
|
|
|
|
use Countable;
|
|
|
|
|
use IteratorAggregate;
|
|
|
|
|
use JsonSerializable;
|
|
|
|
|
use OutOfBoundsException;
|
|
|
|
|
use Throwable;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -52,7 +53,18 @@ interface IImmutableCollection extends IteratorAggregate, JsonSerializable, Coun
|
|
|
|
|
*
|
|
|
|
|
* @return TValue|null The value
|
|
|
|
|
*/
|
|
|
|
|
public function get ($key): mixed;
|
|
|
|
|
public function get ($key);
|
|
|
|
|
/**
|
|
|
|
|
* Get the value at an offset
|
|
|
|
|
*
|
|
|
|
|
* @param int $offset The offset
|
|
|
|
|
*
|
|
|
|
|
* @return TValue The value
|
|
|
|
|
*
|
|
|
|
|
* @throws OutOfBoundsException If the offset is not valid
|
|
|
|
|
*/
|
|
|
|
|
public function getFromOffset (int $offset);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the first key of a value or null if not found
|
|
|
|
|
*
|
|
|
|
@ -62,6 +74,50 @@ interface IImmutableCollection extends IteratorAggregate, JsonSerializable, Coun
|
|
|
|
|
* @return TKey|null
|
|
|
|
|
*/
|
|
|
|
|
public function key ($value, bool $strict = false);
|
|
|
|
|
/**
|
|
|
|
|
* Get the key at an offset
|
|
|
|
|
*
|
|
|
|
|
* @param int $offset The offset
|
|
|
|
|
*
|
|
|
|
|
* @return TKey The key
|
|
|
|
|
*
|
|
|
|
|
* @throws OutOfBoundsException If the offset is not valid
|
|
|
|
|
*/
|
|
|
|
|
public function keyFromOffset (int $offset);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the value of the first element
|
|
|
|
|
*
|
|
|
|
|
* @return TValue The value
|
|
|
|
|
*
|
|
|
|
|
* @throws OutOfBoundsException If the collection is empty
|
|
|
|
|
*/
|
|
|
|
|
public function first ();
|
|
|
|
|
/**
|
|
|
|
|
* Get the key of the first element
|
|
|
|
|
*
|
|
|
|
|
* @return TKey The key
|
|
|
|
|
*
|
|
|
|
|
* @throws OutOfBoundsException If the collection is empty
|
|
|
|
|
*/
|
|
|
|
|
public function firstKey ();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the value of the last element
|
|
|
|
|
*
|
|
|
|
|
* @return TValue The value
|
|
|
|
|
*
|
|
|
|
|
* @throws OutOfBoundsException If the collection is empty
|
|
|
|
|
*/
|
|
|
|
|
public function last ();
|
|
|
|
|
/**
|
|
|
|
|
* Get the key of the last element
|
|
|
|
|
*
|
|
|
|
|
* @return TKey The key
|
|
|
|
|
*
|
|
|
|
|
* @throws OutOfBoundsException If the collection is empty
|
|
|
|
|
*/
|
|
|
|
|
public function lastKey ();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Extract a slice of the collection
|
|
|
|
@ -72,6 +128,8 @@ interface IImmutableCollection extends IteratorAggregate, JsonSerializable, Coun
|
|
|
|
|
* @param int|null $length The maximum length. Null if until end of the collection
|
|
|
|
|
*
|
|
|
|
|
* @return static<TKey, TValue> The result collection
|
|
|
|
|
*
|
|
|
|
|
* @throws OutOfBoundsException If the offset is not valid
|
|
|
|
|
*/
|
|
|
|
|
public function slice (int $offset, ?int $length = null): static;
|
|
|
|
|
|
|
|
|
|