PartInterface
in
Contract for every DiscordPHP "Part" — the hydrated objects returned for Discord API entities (users, channels, messages, …). Defines construction, attribute access via mutators, `ArrayAccess`, (de)serialization and the attribute projections (`getCreatableAttributes()` / `getUpdatableAttributes()`) the repositories use when POST/PATCHing. {@see Part} is the concrete base.
Tags
Table of Contents
Methods
- __construct() : mixed
- __debugInfo() : array<string|int, mixed>
- Debug representation for `var_dump()`.
- __get() : mixed
- Magic getter for an attribute or accessor mutator.
- __serialize() : array<string|int, mixed>
- The Part's attributes, for PHP's native `serialize()`.
- __set() : void
- Magic setter for an attribute or mutator.
- __toString() : string
- A short string representation of the Part.
- __unserialize() : void
- Restores the Part from the payload of PHP's native `unserialize()`.
- createOf() : self
- Hydrates a new Part of `$class` from `$data` using this Part's client.
- fetch() : PromiseInterface
- Fetches the full Part from the Discord API and refills it in place.
- fill() : void
- Mass-assigns `$attributes` (respecting the `$fillable` whitelist).
- getCreatableAttributes() : array<string|int, mixed>
- The attribute subset sent when creating this Part (POST).
- getDiscord() : Discord
- The Discord client this Part belongs to.
- getPublicAttributes() : array<string|int, mixed>
- The attributes safe to expose publicly (secrets stripped).
- getRawAttributes() : array<string|int, mixed>
- The raw, unmutated attribute array.
- getRepositoryAttributes() : array<string|int, mixed>
- The attributes the owning repository binds into its endpoint URIs.
- getUpdatableAttributes() : array<string|int, mixed>
- The attribute subset sent when updating this Part (PATCH).
- isPartial() : bool
- Whether the Part holds only a partial set of attributes.
- jsonSerialize() : array<string|int, mixed>
- The Part's public attributes, for `json_encode()`.
- offsetExists() : bool
- Whether the attribute at `$key` is set (ArrayAccess).
- offsetGet() : mixed
- Gets the attribute at `$key` (ArrayAccess).
- offsetSet() : void
- Sets the attribute at `$key` (ArrayAccess).
- offsetUnset() : void
- Unsets the attribute at `$key` (ArrayAccess).
- serialize() : string|null
- Serialises the Part's attributes to a string, or null on failure.
- unserialize() : void
- Restores the Part from a string produced by {@see serialize()}.
Methods
__construct()
public
__construct(Discord $discord[, array<string|int, mixed> $attributes = [] ][, bool $created = false ]) : mixed
Parameters
- $discord : Discord
- $attributes : array<string|int, mixed> = []
-
Initial attribute values.
- $created : bool = false
-
Whether the Part already exists on Discord.
__debugInfo()
Debug representation for `var_dump()`.
public
__debugInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>__get()
Magic getter for an attribute or accessor mutator.
public
__get(string $key) : mixed
Parameters
- $key : string
__serialize()
The Part's attributes, for PHP's native `serialize()`.
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__set()
Magic setter for an attribute or mutator.
public
__set(string $key, mixed $value) : void
Parameters
- $key : string
- $value : mixed
__toString()
A short string representation of the Part.
public
__toString() : string
Return values
string__unserialize()
Restores the Part from the payload of PHP's native `unserialize()`.
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
createOf()
Hydrates a new Part of `$class` from `$data` using this Part's client.
public
createOf(string $class, array<string|int, mixed>|object $data) : self
Parameters
- $class : string
- $data : array<string|int, mixed>|object
Return values
selffetch()
Fetches the full Part from the Discord API and refills it in place.
public
fetch() : PromiseInterface
Return values
PromiseInterfacefill()
Mass-assigns `$attributes` (respecting the `$fillable` whitelist).
public
fill(array<string|int, mixed> $attributes) : void
Parameters
- $attributes : array<string|int, mixed>
getCreatableAttributes()
The attribute subset sent when creating this Part (POST).
public
getCreatableAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getDiscord()
The Discord client this Part belongs to.
public
getDiscord() : Discord
Return values
DiscordgetPublicAttributes()
The attributes safe to expose publicly (secrets stripped).
public
getPublicAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getRawAttributes()
The raw, unmutated attribute array.
public
getRawAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getRepositoryAttributes()
The attributes the owning repository binds into its endpoint URIs.
public
getRepositoryAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getUpdatableAttributes()
The attribute subset sent when updating this Part (PATCH).
public
getUpdatableAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>isPartial()
Whether the Part holds only a partial set of attributes.
public
isPartial() : bool
Return values
booljsonSerialize()
The Part's public attributes, for `json_encode()`.
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>offsetExists()
Whether the attribute at `$key` is set (ArrayAccess).
public
offsetExists(mixed $key) : bool
Parameters
- $key : mixed
Return values
booloffsetGet()
Gets the attribute at `$key` (ArrayAccess).
public
offsetGet(mixed $key) : mixed
Parameters
- $key : mixed
Attributes
- #[ReturnTypeWillChange]
offsetSet()
Sets the attribute at `$key` (ArrayAccess).
public
offsetSet(mixed $key, mixed $value) : void
Parameters
- $key : mixed
- $value : mixed
offsetUnset()
Unsets the attribute at `$key` (ArrayAccess).
public
offsetUnset(mixed $key) : void
Parameters
- $key : mixed
serialize()
Serialises the Part's attributes to a string, or null on failure.
public
serialize() : string|null
Return values
string|nullunserialize()
Restores the Part from a string produced by {@see serialize()}.
public
unserialize(mixed $data) : void
Parameters
- $data : mixed