Factory
in package
Builds {@see Part}s from raw Bot API payloads.
The unit of work is a Telegram type token - the same strings the spec uses:
"Message", "Array of Update", "Integer", "Boolean". Generated parts
declare them in $casts and generated API methods declare them as their return
type, so one hydrator covers nested objects and call results alike.
Tags
Table of Contents
Constants
- PART_NAMESPACE : mixed = 'Telegram\Parts\\'
- Where generated parts live.
Properties
Methods
- __construct() : mixed
- create() : mixed
- Hydrates a value according to its Telegram type token.
- getTelegram() : Telegram
- part() : Part
- Builds one part, resolving a union parent to the concrete subtype the payload describes.
- partClassFor() : Part>|null
- The part class a Telegram type name maps to, or null when the token is a primitive ("Integer", "String", "Boolean", "Float", "InputFile").
Constants
PART_NAMESPACE
Where generated parts live.
public
mixed
PART_NAMESPACE
= 'Telegram\Parts\\'
Properties
$telegram read-only
private
Telegram
$telegram
Methods
__construct()
public
__construct(Telegram $telegram) : mixed
Parameters
- $telegram : Telegram
create()
Hydrates a value according to its Telegram type token.
public
create(string $token, mixed $value) : mixed
Scalars pass through untouched, Array of X becomes a Collection of
hydrated members, and an object type becomes the matching part - resolving
to a concrete subtype when the token names a union.
Parameters
- $token : string
- $value : mixed
getTelegram()
public
getTelegram() : Telegram
Return values
Telegrampart()
Builds one part, resolving a union parent to the concrete subtype the payload describes.
public
part(Part> $class[, array<string, mixed> $attributes = [] ]) : Part
Parameters
- $class : Part>
- $attributes : array<string, mixed> = []
Tags
Return values
PartpartClassFor()
The part class a Telegram type name maps to, or null when the token is a primitive ("Integer", "String", "Boolean", "Float", "InputFile").
public
partClassFor(string $type) : Part>|null
Parameters
- $type : string