TelegramPHP Documentation

AbstractRepository
in package
implements Countable, IteratorAggregate

AbstractYes

An in-memory view of the parts of one kind this client has seen.

DiscordPHP repositories are backed by list endpoints; the Bot API has none - a bot learns about a chat or a user by being told about them in an update, and can look one up only if it already holds an identifier. So a repository here is a cache that updates fill in, with fetch() going to Telegram for a fresh copy where a method for that exists.

Tags
template
author

Valithor Obsidion valithor@valgorithms.com

Table of Contents

Interfaces

Countable
IteratorAggregate

Properties

$discrim  : string
The attribute that identifies a row.
$items  : Collection<string|int, TPart>
$part  : TPart>
The part class this repository holds.
$telegram  : Telegram

Methods

__construct()  : mixed
all()  : Collection<string|int, TPart>
cache()  : TPart
Remembers a part, or merges it into the one already held under that id.
clear()  : void
count()  : int
fetch()  : PromiseInterface<string|int, TPart>
A fresh copy from Telegram, cached on the way back.
fetchOrGet()  : PromiseInterface<string|int, TPart>
The cached part if there is one, otherwise a fresh copy from Telegram.
get()  : TPart|null
The cached part with this id, if it has been seen.
getIterator()  : Traversable
has()  : bool
normalise()  : int|string
Telegram ids are integers, but they arrive as strings often enough - out of a config file, off a command argument - that a lookup has to accept both.

Properties

Methods

all()

public all() : Collection<string|int, TPart>
Return values
Collection<string|int, TPart>

cache()

Remembers a part, or merges it into the one already held under that id.

public cache(TPart $part) : TPart
Parameters
$part : TPart
Return values
TPart

The cached part - the merged one when an entry already existed.

fetch()

A fresh copy from Telegram, cached on the way back.

public abstract fetch(int|string $id) : PromiseInterface<string|int, TPart>
Parameters
$id : int|string
Return values
PromiseInterface<string|int, TPart>

fetchOrGet()

The cached part if there is one, otherwise a fresh copy from Telegram.

public fetchOrGet(int|string $id) : PromiseInterface<string|int, TPart>
Parameters
$id : int|string
Return values
PromiseInterface<string|int, TPart>

get()

The cached part with this id, if it has been seen.

public get(int|string $id) : TPart|null
Parameters
$id : int|string
Return values
TPart|null

has()

public has(int|string $id) : bool
Parameters
$id : int|string
Return values
bool

normalise()

Telegram ids are integers, but they arrive as strings often enough - out of a config file, off a command argument - that a lookup has to accept both.

protected static normalise(int|string $id) : int|string

A @channelusername is left alone; it is not an id at all.

Parameters
$id : int|string
Return values
int|string
On this page

Search results