ThreadRepository
extends AbstractRepository
in package
Contains threads on a channel.
Tags
Table of Contents
- $cache : CacheWrapper
- $discrim : string
- The collection discriminator.
- $cache : CacheWrapper
- $class : mixed
- {@inheritDoc}
- $discrim : string
- The collection discriminator.
- $endpoints : array<string|int, mixed>
- Endpoints for interacting with the Discord servers.
- $factory : Factory
- The parts factory.
- $http : Http
- The HTTP client.
- $items : array<string|int, mixed>
- The items contained in the collection.
- $vars : array<string|int, mixed>
- Variables that are related to the repository.
- __construct() : mixed
- Create a new collection.
- __debugInfo() : array<string|int, mixed>
- Returns an item that will be displayed for debugging.
- __get() : mixed
- __serialize() : array<string|int, mixed>
- Returns the string representation of the collection.
- __unserialize() : void
- Unserializes the collection.
- active() : ExtendedPromiseInterface<string|int, Collection<string|int, Thread>>
- Fetches all the active threads on the channel.
- archived() : ExtendedPromiseInterface<string|int, Collection<string|int, Thread>>
- Fetches archived threads based on a set of options.
- clear() : void
- Clears the collection.
- count() : int
- Counts the amount of objects in the collection.
- create() : Part
- Builds a new, empty part.
- delete() : ExtendedPromiseInterface<string|int, Part>
- Attempts to delete a part on the Discord servers.
- fetch() : ExtendedPromiseInterface<string|int, Part>
- Gets a part from the repository or Discord servers.
- fill() : Collection
- Fills an array of items into the collection.
- filter() : Collection
- Runs a filter callback over the collection and returns a new collection based on the response of the callback.
- find() : mixed
- Runs a filter callback over the collection and returns the first item where the callback returns `true` when given the item.
- find() : Part|null
- Runs a filter callback over the repository and returns the first part where the callback returns `true` when given the part.
- first() : mixed
- Returns the first element of the collection.
- first() : Part|null
- Returns the first cached part.
- for() : static
- Creates a collection for a class.
- fresh() : ExtendedPromiseInterface<string|int, Part>
- Returns a part with fresh values.
- freshen() : ExtendedPromiseInterface<string|int, static>
- Freshens the repository cache.
- from() : static
- Creates a collection from an array.
- get() : mixed
- Gets an item from the collection.
- get() : Part|null
- Gets a part from the repository.
- getIterator() : Traversable
- Returns an iterator for the collection.
- has() : bool
- Checks if the array has multiple offsets.
- isset() : bool
- If the collection has an offset.
- jsonSerialize() : array<string|int, mixed>
- Serializes the object to a value that can be serialized natively by json_encode().
- keys() : array<string|int, int>|array<string|int, string>
- Get the keys of the items.
- last() : mixed
- Returns the last element of the collection.
- last() : Part|null
- Returns the last cached part.
- map() : Collection
- Runs a callback over the collection and creates a new collection.
- merge() : Collection
- Merges another collection into this collection.
- offsetExists() : bool
- If the collection has an offset.
- offsetGet() : mixed
- Gets an item from the collection.
- offsetSet() : void
- Sets an item into the collection.
- offsetUnset() : void
- Unsets an index from the collection.
- pull() : mixed
- Pulls an item from the collection.
- pull() : Part|mixed
- Pulls a part from the repository.
- push() : Collection
- Pushes items to the collection.
- pushItem() : Collection
- Pushes a single item to the collection.
- save() : ExtendedPromiseInterface<string|int, Part>
- Attempts to save a part to the Discord servers.
- serialize() : string
- Returns the string representation of the collection.
- set() : mixed
- Sets a value in the collection.
- toArray() : array<string|int, mixed>
- Converts the collection to an array.
- unserialize() : void
- Unserializes the collection.
- cacheFreshen() : ExtendedPromiseInterface<string|int, static>
- handleThreadPaginationResponse() : mixed
- Handles a response from one of the thread pagination endpoints.
Properties
$cache read-only
public
CacheWrapper
$cache
The react/cache wrapper.
$discrim read-only
The collection discriminator.
public
string
$discrim
The discriminator.
$cache
protected
CacheWrapper
$cache
$class
{@inheritDoc}
protected
mixed
$class
= \Discord\Parts\Thread\Thread::class
$discrim
The collection discriminator.
protected
string
$discrim
$endpoints
Endpoints for interacting with the Discord servers.
protected
array<string|int, mixed>
$endpoints
= ['all' => \Discord\Http\Endpoint::GUILD_THREADS_ACTIVE, 'get' => \Discord\Http\Endpoint::THREAD, 'update' => \Discord\Http\Endpoint::THREAD, 'delete' => \Discord\Http\Endpoint::THREAD, 'create' => \Discord\Http\Endpoint::CHANNEL_THREADS]
Endpoints.
$factory
The parts factory.
protected
Factory
$factory
Parts factory.
$http
The HTTP client.
protected
Http
$http
Client.
$items
The items contained in the collection.
protected
array<string|int, mixed>
$items
$vars
Variables that are related to the repository.
protected
array<string|int, mixed>
$vars
= []
Variables.
Methods
__construct()
Create a new collection.
public
__construct([mixed $items = [] ][, string $discrim = 'id' ][, string|null $class = null ]) : mixed
Parameters
- $items : mixed = []
- $discrim : string = 'id'
- $class : string|null = null
Return values
mixed —__debugInfo()
Returns an item that will be displayed for debugging.
public
__debugInfo() : array<string|int, mixed>
Return values
array<string|int, mixed> —__get()
public
__get(string $key) : mixed
Parameters
- $key : string
Return values
mixed —__serialize()
Returns the string representation of the collection.
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —__unserialize()
Unserializes the collection.
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Return values
void —active()
Fetches all the active threads on the channel.
public
active() : ExtendedPromiseInterface<string|int, Collection<string|int, Thread>>
Tags
Return values
ExtendedPromiseInterface<string|int, Collection<string|int, Thread>> —archived()
Fetches archived threads based on a set of options.
public
archived([bool $private = false ][, bool $joined = false ][, int|null $limit = null ][, Thread|string|null $before = null ]) : ExtendedPromiseInterface<string|int, Collection<string|int, Thread>>
Parameters
- $private : bool = false
-
Whether we are fetching archived private threads.
- $joined : bool = false
-
Whether we are fetching private threads that we have joined. Note
private
cannot be false whilejoined
is true. - $limit : int|null = null
-
The number of threads to return, null to return all.
- $before : Thread|string|null = null
-
Retrieve threads before this thread. Takes a thread object or a thread ID.
Tags
Return values
ExtendedPromiseInterface<string|int, Collection<string|int, Thread>> —clear()
Clears the collection.
public
clear() : void
Return values
void —count()
Counts the amount of objects in the collection.
public
count() : int
Return values
int —create()
Builds a new, empty part.
public
create([array<string|int, mixed> $attributes = [] ][, bool $created = false ]) : Part
Parameters
- $attributes : array<string|int, mixed> = []
-
The attributes for the new part.
- $created : bool = false
Tags
Return values
Part —The new part.
delete()
Attempts to delete a part on the Discord servers.
public
delete(Part|string $part[, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Part>
Parameters
- $part : Part|string
-
The part to delete.
- $reason : string|null = null
-
Reason for Audit Log (if supported).
Tags
Return values
ExtendedPromiseInterface<string|int, Part> —fetch()
Gets a part from the repository or Discord servers.
public
fetch(string $id[, bool $fresh = false ]) : ExtendedPromiseInterface<string|int, Part>
Parameters
- $id : string
-
The ID to search for.
- $fresh : bool = false
-
Whether we should skip checking the cache.
Tags
Return values
ExtendedPromiseInterface<string|int, Part> —fill()
Fills an array of items into the collection.
public
fill(array<string|int, mixed> $items) : Collection
Parameters
- $items : array<string|int, mixed>
Return values
Collection —filter()
Runs a filter callback over the collection and returns a new collection based on the response of the callback.
public
filter(callable $callback) : Collection
Parameters
- $callback : callable
Return values
Collection —find()
Runs a filter callback over the collection and returns the first item where the callback returns `true` when given the item.
public
find(callable $callback) : mixed
Parameters
- $callback : callable
Return values
mixed —null
if no items returns true
when called in the $callback
.
find()
Runs a filter callback over the repository and returns the first part where the callback returns `true` when given the part.
public
find() : Part|null
Return values
Part|null —null
if no items returns true
when called in the callback.
first()
Returns the first element of the collection.
public
first() : mixed
Return values
mixed —first()
Returns the first cached part.
public
first() : Part|null
Return values
Part|null —for()
Creates a collection for a class.
public
static for(string $class[, string $discrim = 'id' ]) : static
Parameters
- $class : string
- $discrim : string = 'id'
Return values
static —fresh()
Returns a part with fresh values.
public
fresh(Part $part[, array<string|int, mixed> $queryparams = [] ]) : ExtendedPromiseInterface<string|int, Part>
Parameters
- $part : Part
-
The part to get fresh values.
- $queryparams : array<string|int, mixed> = []
-
Query string params to add to the request (no validation)
Tags
Return values
ExtendedPromiseInterface<string|int, Part> —freshen()
Freshens the repository cache.
public
freshen([array<string|int, mixed> $queryparams = [] ]) : ExtendedPromiseInterface<string|int, static>
Parameters
- $queryparams : array<string|int, mixed> = []
-
Query string params to add to the request (no validation)
Tags
Return values
ExtendedPromiseInterface<string|int, static> —from()
Creates a collection from an array.
public
static from([array<string|int, mixed> $items = [] ][, string $discrim = 'id' ][, string $class = null ]) : static
Parameters
- $items : array<string|int, mixed> = []
- $discrim : string = 'id'
- $class : string = null
Return values
static —get()
Gets an item from the collection.
public
get(string $discrim, mixed $key) : mixed
Parameters
- $discrim : string
- $key : mixed
Return values
mixed —get()
Gets a part from the repository.
public
get(string $discrim, mixed $key) : Part|null
Parameters
- $discrim : string
- $key : mixed
Return values
Part|null —getIterator()
Returns an iterator for the collection.
public
getIterator() : Traversable
Return values
Traversable —has()
Checks if the array has multiple offsets.
public
has(array<string|int, mixed> ...$keys) : bool
Parameters
- $keys : array<string|int, mixed>
Return values
bool —isset()
If the collection has an offset.
public
isset(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
bool —jsonSerialize()
Serializes the object to a value that can be serialized natively by json_encode().
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —keys()
Get the keys of the items.
public
keys() : array<string|int, int>|array<string|int, string>
Return values
array<string|int, int>|array<string|int, string> —last()
Returns the last element of the collection.
public
last() : mixed
Return values
mixed —last()
Returns the last cached part.
public
last() : Part|null
Return values
Part|null —map()
Runs a callback over the collection and creates a new collection.
public
map(callable $callback) : Collection
Parameters
- $callback : callable
Return values
Collection —merge()
Merges another collection into this collection.
public
merge(Collection $collection) : Collection
Parameters
- $collection : Collection
Return values
Collection —offsetExists()
If the collection has an offset.
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
bool —offsetGet()
Gets an item from the collection.
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —offsetSet()
Sets an item into the collection.
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Return values
void —offsetUnset()
Unsets an index from the collection.
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Return values
void —pull()
Pulls an item from the collection.
public
pull(mixed $key[, mixed $default = null ]) : mixed
Parameters
- $key : mixed
- $default : mixed = null
Return values
mixed —pull()
Pulls a part from the repository.
public
pull(string|int $key, mixed $default) : Part|mixed
Parameters
- $key : string|int
- $default : mixed
Return values
Part|mixed —push()
Pushes items to the collection.
public
push(mixed ...$items) : Collection
Parameters
- $items : mixed
Return values
Collection —pushItem()
Pushes a single item to the collection.
public
pushItem(mixed $item) : Collection
Parameters
- $item : mixed
Return values
Collection —save()
Attempts to save a part to the Discord servers.
public
save(Part $part[, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Part>
Parameters
- $part : Part
-
The part to save.
- $reason : string|null = null
-
Reason for Audit Log (if supported).
Tags
Return values
ExtendedPromiseInterface<string|int, Part> —serialize()
Returns the string representation of the collection.
public
serialize() : string
Return values
string —set()
Sets a value in the collection.
public
set(mixed $offset, mixed $value) : mixed
Parameters
- $offset : mixed
- $value : mixed
Return values
mixed —toArray()
Converts the collection to an array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —unserialize()
Unserializes the collection.
public
unserialize(string $serialized) : void
Parameters
- $serialized : string
Return values
void —cacheFreshen()
protected
cacheFreshen(mixed $response) : ExtendedPromiseInterface<string|int, static>
Parameters
- $response : mixed
Return values
ExtendedPromiseInterface<string|int, static> —handleThreadPaginationResponse()
Handles a response from one of the thread pagination endpoints.
private
handleThreadPaginationResponse(object $response) : mixed
Parameters
- $response : object