interface UserStorageInterface implements StorageInterface (View source)

Something all user storages implement. The storage also is used as factory.

Methods

mixed
current()

Returns the current element. From Iterator interface.

mixed
key()

Fetch the key from the current element. From Iterator interface.

mixed|false
next()

Advances the internal pointer. From Iterator interface.

mixed|false
rewind()

Resets the internal pointer. From Iterator interface.

bool
valid()

Checks if current position is valid. From Iterator interface.

mixed[]
all()

Returns all items.

int
count()

Returns the total number of items. From Countable interface.

copy()

Returns a copy of itself. This does not make a copy of the stored data.

bool
has(mixed $key)

Determines if a given key exists in the collection.

mixed|null
get(mixed $key)

Returns the item at a given key. If the key does not exist, null is returned.

$this
set(mixed $key, mixed $value)

Sets a key-value pair.

$this
delete(mixed $key)

Removes an item.

$this
clear()

Clears the Storage.

int|null
indexOf(mixed $value)

Returns the position of the given value in the storage. Returns null if the given value couldn't be found.

filter(callable $closure)

Filters the storage by a given callback, keeping only those items that pass a given truth test. Returns a new Storage instance.

mixed|null
first(callable|null $closure = null)

Returns the first element that passes a given truth test.

mixed|null
last(callable|null $closure = null)

Returns the last element that passes a given truth test.

mixed|null|void
reduce(callable $closure, mixed|null $carry = null)

Reduces the collection to a single value, passing the result of each iteration into the subsequent iteration.

sort(bool $descending = false, int $options = \SORT_REGULAR)

Sorts the collection. Returns a new Storage instance.

Collection
sortKey(bool $descending = false, int $options = \SORT_REGULAR)

Sorts the collection by key. Returns a new Storage instance.

Collection
sortCustom(callable $closure)

Sorts the collection using a custom sorting function. Returns a new Storage instance.

Collection
sortCustomKey(callable $closure)

Sorts the collection by key using a custom sorting function. Returns a new Storage instance.

int
max(mixed $key = '')

Return the maximum value of a given key.

int
min(mixed|null $key = null)

Return the minimum value of a given key.

resolve(User|GuildMember|string|int $user)

Resolves given data to an user.

User|null
patch(array $user)

Patches an user (retrieves the user if the user exists), returns null if only the ID is in the array, or creates an user.

factory(array $data, bool $userFetched = false)

Factory to create (or retrieve existing) users.

Details

mixed current()

Returns the current element. From Iterator interface.

Return Value

mixed

mixed key()

Fetch the key from the current element. From Iterator interface.

Return Value

mixed

mixed|false next()

Advances the internal pointer. From Iterator interface.

Return Value

mixed|false

mixed|false rewind()

Resets the internal pointer. From Iterator interface.

Return Value

mixed|false

bool valid()

Checks if current position is valid. From Iterator interface.

Return Value

bool

mixed[] all()

Returns all items.

Return Value

mixed[]

int count()

Returns the total number of items. From Countable interface.

Return Value

int

StorageInterface copy()

Returns a copy of itself. This does not make a copy of the stored data.

Return Value

StorageInterface

bool has(mixed $key)

Determines if a given key exists in the collection.

Parameters

mixed $key

Return Value

bool

Exceptions

InvalidArgumentException

mixed|null get(mixed $key)

Returns the item at a given key. If the key does not exist, null is returned.

Parameters

mixed $key

Return Value

mixed|null

Exceptions

InvalidArgumentException

$this set(mixed $key, mixed $value)

Sets a key-value pair.

Parameters

mixed $key
mixed $value

Return Value

$this

Exceptions

InvalidArgumentException

$this delete(mixed $key)

Removes an item.

Parameters

mixed $key

Return Value

$this

$this clear()

Clears the Storage.

Return Value

$this

int|null indexOf(mixed $value)

Returns the position of the given value in the storage. Returns null if the given value couldn't be found.

Parameters

mixed $value

Return Value

int|null

StorageInterface filter(callable $closure)

Filters the storage by a given callback, keeping only those items that pass a given truth test. Returns a new Storage instance.

Parameters

callable $closure

Return Value

StorageInterface

mixed|null first(callable|null $closure = null)

Returns the first element that passes a given truth test.

Parameters

callable|null $closure

Return Value

mixed|null

mixed|null last(callable|null $closure = null)

Returns the last element that passes a given truth test.

Parameters

callable|null $closure

Return Value

mixed|null

mixed|null|void reduce(callable $closure, mixed|null $carry = null)

Reduces the collection to a single value, passing the result of each iteration into the subsequent iteration.

Parameters

callable $closure
mixed|null $carry

Return Value

mixed|null|void

StorageInterface sort(bool $descending = false, int $options = \SORT_REGULAR)

Sorts the collection. Returns a new Storage instance.

Parameters

bool $descending
int $options

Return Value

StorageInterface

Collection sortKey(bool $descending = false, int $options = \SORT_REGULAR)

Sorts the collection by key. Returns a new Storage instance.

Parameters

bool $descending
int $options

Return Value

Collection

Collection sortCustom(callable $closure)

Sorts the collection using a custom sorting function. Returns a new Storage instance.

Parameters

callable $closure Callback specification: function ($a, $b): int

Return Value

Collection

Collection sortCustomKey(callable $closure)

Sorts the collection by key using a custom sorting function. Returns a new Storage instance.

Parameters

callable $closure Callback specification: function ($a, $b): int

Return Value

Collection

int max(mixed $key = '')

Return the maximum value of a given key.

Parameters

mixed $key

Return Value

int

int min(mixed|null $key = null)

Return the minimum value of a given key.

Parameters

mixed|null $key

Return Value

int

User resolve(User|GuildMember|string|int $user)

Resolves given data to an user.

Parameters

User|GuildMember|string|int $user string/int = user ID

Return Value

User

Exceptions

InvalidArgumentException

User|null patch(array $user)

Patches an user (retrieves the user if the user exists), returns null if only the ID is in the array, or creates an user.

Parameters

array $user

Return Value

User|null

User factory(array $data, bool $userFetched = false)

Factory to create (or retrieve existing) users.

Parameters

array $data
bool $userFetched

Return Value

User