TelegramPHP Documentation

Factory
in package

FinalYes

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
author

Valithor Obsidion valithor@valgorithms.com

Table of Contents

Constants

PART_NAMESPACE  : mixed = 'Telegram\Parts\\'
Where generated parts live.

Properties

$telegram  : Telegram

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

Methods

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

part()

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
throws
PartException

When the class does not exist or a union cannot be resolved.

Return values
Part

partClassFor()

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
Return values
Part>|null
On this page

Search results