Collection extends Collection
Taxonomy collection class. Represents a collection of vocabularies, providing methods to retrieve vocabularies by their ID.
Table of Contents
Properties
Methods
- __construct() : mixed
- __toString() : string
- Returns the collection ID.
- add() : CollectionInterface
- Add an item or throw an exception if exists.
- count() : int
- Implements Countable.
- filter() : CollectionInterface
- Filters items using a callback function.
- first() : ItemInterface|null
- Retrieves the first item.
- get() : Vocabulary
- Retrieves an item or throw an exception if not exists.
- getId() : string
- Returns the collection's identifier.
- getIterator() : ArrayIterator
- Implements \IteratorAggregate.
- getPosition() : int
- Retrieves an item position or throw an exception if not exists.
- has() : bool
- Does the item $id exists?
- keys() : array<string|int, mixed>
- Retrieves all keys.
- last() : ItemInterface|null
- {@inheritdoc}
- map() : CollectionInterface
- Applies a callback to items.
- offsetExists() : bool
- Implements \ArrayAccess.
- offsetGet() : CollectionInterface|ItemInterface|null
- Implements \ArrayAccess.
- offsetSet() : void
- Implements \ArrayAccess.
- offsetUnset() : void
- Implements \ArrayAccess.
- remove() : CollectionInterface
- Removes an item or throw an exception if not exists.
- replace() : CollectionInterface
- Replaces an item or throw an exception if not exists.
- reverse() : CollectionInterface
- Reverse items order.
- setId() : BaseInterface
- Set the collection's identifier.
- toArray() : array<string|int, mixed>
- Returns collection as array.
- toJson() : string
- Returns a JSON string of items.
- usort() : CollectionInterface
- Implements usort.
- searchItem() : array<string|int, mixed>|null
- Search an item by ID.
Properties
$id
Collection's identifier.
protected
string
$id
$items
Collection's items.
protected
array<string|int, mixed>
$items
= []
Methods
__construct()
public
__construct(string $id[, array<string|int, mixed> $items = [] ]) : mixed
Parameters
- $id : string
- $items : array<string|int, mixed> = []
__toString()
Returns the collection ID.
public
__toString() : string
Return values
stringadd()
Add an item or throw an exception if exists.
public
add(ItemInterface $item) : CollectionInterface
Parameters
- $item : ItemInterface
Tags
Return values
CollectionInterfacecount()
Implements Countable.
public
count() : int
Return values
intfilter()
Filters items using a callback function.
public
filter(Closure $callback) : CollectionInterface
Parameters
- $callback : Closure
Return values
CollectionInterfacefirst()
Retrieves the first item.
public
first() : ItemInterface|null
Return values
ItemInterface|nullget()
Retrieves an item or throw an exception if not exists.
public
get(string $id) : Vocabulary
Parameters
- $id : string
Return values
VocabularygetId()
Returns the collection's identifier.
public
getId() : string
Return values
stringgetIterator()
Implements \IteratorAggregate.
public
getIterator() : ArrayIterator
Return values
ArrayIteratorgetPosition()
Retrieves an item position or throw an exception if not exists.
public
getPosition(string $id) : int
Parameters
- $id : string
Tags
Return values
inthas()
Does the item $id exists?
public
has(string $id) : bool
Parameters
- $id : string
Return values
boolkeys()
Retrieves all keys.
public
keys() : array<string|int, mixed>
Return values
array<string|int, mixed>last()
{@inheritdoc}
public
last() : ItemInterface|null
Return values
ItemInterface|nullmap()
Applies a callback to items.
public
map(Closure $callback) : CollectionInterface
Parameters
- $callback : Closure
Return values
CollectionInterfaceoffsetExists()
Implements \ArrayAccess.
public
offsetExists(string $offset) : bool
Parameters
- $offset : string
Attributes
- #[ReturnTypeWillChange]
Return values
booloffsetGet()
Implements \ArrayAccess.
public
offsetGet(string $offset) : CollectionInterface|ItemInterface|null
Parameters
- $offset : string
Attributes
- #[ReturnTypeWillChange]
Return values
CollectionInterface|ItemInterface|nulloffsetSet()
Implements \ArrayAccess.
public
offsetSet(mixed $offset, ItemInterface $value) : void
Parameters
- $offset : mixed
- $value : ItemInterface
Tags
Attributes
- #[ReturnTypeWillChange]
offsetUnset()
Implements \ArrayAccess.
public
offsetUnset(string $offset) : void
Parameters
- $offset : string
Attributes
- #[ReturnTypeWillChange]
remove()
Removes an item or throw an exception if not exists.
public
remove(string $id) : CollectionInterface
Parameters
- $id : string
Tags
Return values
CollectionInterfacereplace()
Replaces an item or throw an exception if not exists.
public
replace(string $id, ItemInterface $item) : CollectionInterface
Parameters
- $id : string
- $item : ItemInterface
Tags
Return values
CollectionInterfacereverse()
Reverse items order.
public
reverse() : CollectionInterface
Return values
CollectionInterfacesetId()
Set the collection's identifier.
public
setId(string $id) : BaseInterface
Parameters
- $id : string
Return values
BaseInterfacetoArray()
Returns collection as array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>toJson()
Returns a JSON string of items.
public
toJson() : string
Return values
stringusort()
Implements usort.
public
usort([Closure|null $callback = null ]) : CollectionInterface
Parameters
- $callback : Closure|null = null
Return values
CollectionInterfacesearchItem()
Search an item by ID.
protected
searchItem(string $id) : array<string|int, mixed>|null
Parameters
- $id : string