phpbotgram

StringField extends BaseField
in package

FinalYes

Typed F-DSL wrapper for string-valued Telegram fields (e.g.

Message::$text, User::$firstName). Exposes string-specific predicates that bottom out in the underlying MagicFilter chain.

Each terminal method (equals, contains, startsWith, …) builds a chain operation and bridges the result to a dispatcher-consumable Filter. The two transform methods (lower, upper) and the length projection (len) return new field instances so the caller can keep composing typed comparators on top.

Mirrors the design spec § "Magic-filter runtime + F-DSL" — Layer 3 StringField sketch, minus the codegen-only conveniences (which live on the per-event builders, not the runtime primitive).

Table of Contents

Properties

$chain  : MagicFilter

Methods

__construct()  : mixed
Hold the chain handle directly: codegen passes a freshly-rooted chain (e.g. `MagicFilter::root()->text`) and subclass methods clone-and- extend it via the chain's immutable append semantics.
asFilter()  : Filter
Bridge the wrapped chain to a `Filter`. Used by callers that want the raw chain verdict without going through a typed comparator — e.g. an existence check on a nullable-typed field where the underlying `MagicFilter::asFilter()` reject-on-null behaviour is exactly what the user wants.
contains()  : Filter
Substring-containment check. Delegates to MagicFilter's `contains` op which uses `str_contains` for string subjects.
endsWith()  : Filter
Suffix match — delegates to `str_ends_with`.
equals()  : Filter
Exact-match comparator. `F->text->equals('cancel')` accepts a message whose text is exactly `'cancel'`.
in()  : Filter
Set-membership check: accept when the running string is `==`-equal to any value in `$values`. The list is captured by value at chain-build time so later mutations don't affect the filter.
len()  : IntField
Length projection: extends the chain with a `strlen`/`count` transform and surfaces the result as an `IntField` so callers can stack int comparators (`F->text->len()->gt(5)`).
lower()  : StringField
UTF-8 aware lowercase transform. Returns a fresh `StringField` so subsequent string comparators see the lowercased running value — enabling `F->text->lower()->equals('cancel')` to accept any case.
startsWith()  : Filter
Prefix match — delegates to `str_starts_with`.
upper()  : StringField
UTF-8 aware uppercase transform. Mirrors `lower()`.

Properties

Methods

__construct()

Hold the chain handle directly: codegen passes a freshly-rooted chain (e.g. `MagicFilter::root()->text`) and subclass methods clone-and- extend it via the chain's immutable append semantics.

public __construct(MagicFilter $chain) : mixed
Parameters
$chain : MagicFilter

asFilter()

Bridge the wrapped chain to a `Filter`. Used by callers that want the raw chain verdict without going through a typed comparator — e.g. an existence check on a nullable-typed field where the underlying `MagicFilter::asFilter()` reject-on-null behaviour is exactly what the user wants.

public asFilter() : Filter

Returns a MagicFilterAsFilter instance under the hood; see MagicFilterAsFilter for the bool|array acceptance contract.

Return values
Filter

contains()

Substring-containment check. Delegates to MagicFilter's `contains` op which uses `str_contains` for string subjects.

public contains(string $needle) : Filter
Parameters
$needle : string
Return values
Filter

endsWith()

Suffix match — delegates to `str_ends_with`.

public endsWith(string $suffix) : Filter
Parameters
$suffix : string
Return values
Filter

equals()

Exact-match comparator. `F->text->equals('cancel')` accepts a message whose text is exactly `'cancel'`.

public equals(string $value) : Filter
Parameters
$value : string
Return values
Filter

in()

Set-membership check: accept when the running string is `==`-equal to any value in `$values`. The list is captured by value at chain-build time so later mutations don't affect the filter.

public in(array<int, string> $values) : Filter

Method name avoids the leading-underscore convention used on MagicFilter::in_(); the underscore is necessary on the chain method because in is a PHP keyword in some contexts, but here we're at a method-name boundary and in is unambiguous.

Parameters
$values : array<int, string>
Return values
Filter

len()

Length projection: extends the chain with a `strlen`/`count` transform and surfaces the result as an `IntField` so callers can stack int comparators (`F->text->len()->gt(5)`).

public len() : IntField
Return values
IntField

lower()

UTF-8 aware lowercase transform. Returns a fresh `StringField` so subsequent string comparators see the lowercased running value — enabling `F->text->lower()->equals('cancel')` to accept any case.

public lower() : StringField
Return values
StringField

startsWith()

Prefix match — delegates to `str_starts_with`.

public startsWith(string $prefix) : Filter
Parameters
$prefix : string
Return values
Filter
On this page

Search results