You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.8 KiB
PHP
79 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace jrosset\Collections;
|
|
|
|
/**
|
|
* Interface for a collection
|
|
*
|
|
* @psalm-template TKey of array-key
|
|
* @template-covariant TValue
|
|
* @template-extends IImmutableCollection<TKey, TValue>
|
|
*/
|
|
interface ICollection extends IImmutableCollection {
|
|
/**
|
|
* Set a value to a key
|
|
*
|
|
* @param array-key $key The key
|
|
* @param mixed $value The value
|
|
*
|
|
* @psalm-param TKey $key
|
|
* @psalm-param TValue $value
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function set ($key, $value): self;
|
|
/**
|
|
* Merge one or multiple collections in the current one
|
|
*
|
|
* @param IImmutableCollection ...$collections The collections to merge
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function merge (IImmutableCollection ...$collections): self;
|
|
/**
|
|
* Add one or multiple values
|
|
*
|
|
* @param mixed ...$values The values
|
|
*
|
|
* @psalm-param TValue ...$values
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function add (...$values): self;
|
|
/**
|
|
* Add the <b>values</b> of one or multiple collections
|
|
*
|
|
* @param IImmutableCollection ...$collections The collections to add
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function addCollection (IImmutableCollection ...$collections): self;
|
|
|
|
/**
|
|
* Empties the collection
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function clear (): self;
|
|
/**
|
|
* Delete a key
|
|
*
|
|
* @param array-key $key The key
|
|
*
|
|
* @psalm-param TKey $key
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function remove ($key): self;
|
|
/**
|
|
* Delete all instances of a value
|
|
*
|
|
* @param mixed $value The value
|
|
* @param bool $strict Strict comparison ?
|
|
*
|
|
* @psalm-param TValue $value
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function removeValue ($value, bool $strict = false): self;
|
|
} |