AbstractRepositoryInterface
extends
CollectionInterface
in
Contract for a DiscordPHP repository: a keyed, cached {@see CollectionInterface} of {@see Part}s for one Discord API resource, plus the async CRUD methods (`freshen()`, `fetch()`, `create()`, `save()`, `delete()`) that talk to the Discord REST API and keep the cache in sync. {@see AbstractRepository} is the concrete base every repository extends.
Tags
Table of Contents
Methods
- __construct() : mixed
- __get() : mixed
- Reads an otherwise-protected repository property (`discrim`, `cache`, …).
- cacheGet() : PromiseInterface
- Resolves with the cached item at `$offset`, loading it from the cache backend if needed.
- cachePull() : PromiseInterface
- Removes and resolves with the cached item at `$key` (or `$default`).
- clear() : void
- collect() : ExCollectionInterface
- Returns the repository's items as a new collection.
- create() : Part
- Builds a new, un-saved Part of this repository's class from `$attributes`.
- delete() : PromiseInterface
- Deletes `$part` (a Part or its id) on Discord and removes it from the repository.
- fetch() : PromiseInterface
- Fetches the Part with id `$id`, resolving from cache unless `$fresh` is true.
- filter() : ExCollectionInterface
- find() : mixed
- first() : mixed
- fresh() : PromiseInterface
- Re-fetches `$part` from the Discord API and refills it in place.
- freshen() : PromiseInterface
- Freshens the repository from the Discord API and resolves with itself.
- get() : mixed
- getIterator() : Traversable
- has() : bool
- jsonSerialize() : array<string|int, mixed>
- keys() : array<string|int, mixed>
- last() : mixed
- offsetExists() : bool
- offsetGet() : mixed
- offsetSet() : void
- offsetUnset() : void
- pull() : mixed
- pushItem() : self
- save() : PromiseInterface
- set() : mixed
- toArray() : array<string|int, mixed>
- values() : array<string|int, mixed>
Methods
__construct()
public
__construct(Discord $discord[, array<string|int, mixed> $vars = [] ]) : mixed
Parameters
- $discord : Discord
- $vars : array<string|int, mixed> = []
-
Variables bound into the repository's endpoint URIs.
__get()
Reads an otherwise-protected repository property (`discrim`, `cache`, …).
public
__get(string $key) : mixed
Parameters
- $key : string
cacheGet()
Resolves with the cached item at `$offset`, loading it from the cache backend if needed.
public
cacheGet(mixed $offset) : PromiseInterface
Parameters
- $offset : mixed
Return values
PromiseInterfacecachePull()
Removes and resolves with the cached item at `$key` (or `$default`).
public
cachePull(mixed $key[, mixed $default = null ]) : PromiseInterface
Parameters
- $key : mixed
- $default : mixed = null
Return values
PromiseInterfaceclear()
public
clear() : void
Tags
collect()
Returns the repository's items as a new collection.
public
collect() : ExCollectionInterface
Return values
ExCollectionInterfacecreate()
Builds a new, un-saved Part of this repository's class from `$attributes`.
public
create([array<string|int, mixed>|object $attributes = [] ][, bool $created = false ]) : Part
Parameters
- $attributes : array<string|int, mixed>|object = []
- $created : bool = false
-
Whether the Part should be marked as already existing on Discord.
Return values
Partdelete()
Deletes `$part` (a Part or its id) on Discord and removes it from the repository.
public
delete(Part|string $part[, string|null $reason = null ]) : PromiseInterface
Parameters
- $part : Part|string
- $reason : string|null = null
-
Audit-log reason.
Return values
PromiseInterfacefetch()
Fetches the Part with id `$id`, resolving from cache unless `$fresh` is true.
public
fetch(string $id[, bool $fresh = false ]) : PromiseInterface
Parameters
- $id : string
- $fresh : bool = false
Return values
PromiseInterfacefilter()
public
filter(callable $callback) : ExCollectionInterface
Parameters
- $callback : callable
Tags
Return values
ExCollectionInterfacefind()
public
find(callable $callback) : mixed
Parameters
- $callback : callable
Tags
first()
public
first() : mixed
Tags
fresh()
Re-fetches `$part` from the Discord API and refills it in place.
public
fresh(Part $part[, array<string|int, mixed> $queryparams = [] ]) : PromiseInterface
Parameters
- $part : Part
- $queryparams : array<string|int, mixed> = []
-
Query string parameters for the fetch.
Return values
PromiseInterfacefreshen()
Freshens the repository from the Discord API and resolves with itself.
public
freshen([array<string|int, mixed> $queryparams = [] ]) : PromiseInterface
Parameters
- $queryparams : array<string|int, mixed> = []
-
Query string parameters for the list endpoint.
Return values
PromiseInterfaceget()
public
get(string $discrim, mixed $key) : mixed
Parameters
- $discrim : string
- $key : mixed
Tags
getIterator()
public
& getIterator() : Traversable
Tags
Return values
Traversablehas()
public
has(mixed ...$keys) : bool
Parameters
- $keys : mixed
Tags
Return values
booljsonSerialize()
public
jsonSerialize([bool $assoc = true ]) : array<string|int, mixed>
Parameters
- $assoc : bool = true
Tags
Return values
array<string|int, mixed>keys()
public
keys() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>last()
public
last() : mixed
Tags
offsetExists()
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Tags
Return values
booloffsetGet()
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
Tags
Attributes
- #[ReturnTypeWillChange]
offsetSet()
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Tags
offsetUnset()
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Tags
pull()
public
pull(mixed $key[, mixed $default = null ]) : mixed
Parameters
- $key : mixed
- $default : mixed = null
Tags
pushItem()
public
pushItem(mixed $item) : self
Parameters
- $item : mixed
Tags
Return values
selfsave()
public
save(Part $part[, string|null $reason = null ]) : PromiseInterface
Use Part->save($reason) to ensure permissions are checked.
Parameters
- $part : Part
- $reason : string|null = null
Return values
PromiseInterfaceset()
public
set(mixed $offset, mixed $value) : mixed
Parameters
- $offset : mixed
- $value : mixed
Tags
toArray()
public
toArray([bool $assoc = true ]) : array<string|int, mixed>
Use jsonSerialize
Parameters
- $assoc : bool = true
Return values
array<string|int, mixed>values()
public
values() : array<string|int, mixed>