HelperTrait
Small presentation helpers shared by {@see MTG} and its command handlers for turning MTG API data into Discord output: a mention-safe {@see MessageBuilder} factory and emoji lookup helpers. Pure formatting — no API or model concerns live here.
Tags
Table of Contents
Methods
- __encapsulatedSymbolsToEmojis() : string|null
- Converts encapsulated symbol placeholders within a string to their corresponding emoji representations.
- colorIdentityToInteger() : int|null
- Converts a color identity string to its corresponding integer representation.
- createBuilder() : MessageBuilder
- Creates a new instance of MessageBuilder.
- encapsulated_emoji_str_replace() : string
- Replaces a placeholder in the given string with the string representation of an Emoji object.
- encapsulatedSymbolsToEmojis() : string
- Replaces every `{X}` mana/symbol token in a string with the matching application emoji (stored under the name `X_`, e.g. `{U}` → emoji `U_`).
Methods
__encapsulatedSymbolsToEmojis()
Converts encapsulated symbol placeholders within a string to their corresponding emoji representations.
public
__encapsulatedSymbolsToEmojis(string $subject, string $search) : string|null
Parameters
- $subject : string
-
The input string containing symbol placeholders to be replaced.
- $search : string
-
The symbol name to search for and replace with its emoji.
Tags
Return values
string|null —The string with symbols replaced by emojis, or null if no emoji is found.
colorIdentityToInteger()
Converts a color identity string to its corresponding integer representation.
public
static colorIdentityToInteger(string|null $identity) : int|null
Parameters
- $identity : string|null
-
The color identity string to convert.
Tags
Return values
int|nullcreateBuilder()
Creates a new instance of MessageBuilder.
public
static createBuilder([bool $prevent_mentions = false ]) : MessageBuilder
Optionally prevents mentions in the message by setting allowed mentions to none.
Parameters
- $prevent_mentions : bool = false
-
Whether to prevent mentions in the message. Defaults to false.
Tags
Return values
MessageBuilderencapsulated_emoji_str_replace()
Replaces a placeholder in the given string with the string representation of an Emoji object.
public
static encapsulated_emoji_str_replace(string $search, Emoji $emoji, string $subject) : string
Parameters
- $search : string
- $emoji : Emoji
-
The Emoji object whose string representation will replace the placeholder.
- $subject : string
Tags
Return values
string —The resulting string with the placeholder replaced by the emoji.
encapsulatedSymbolsToEmojis()
Replaces every `{X}` mana/symbol token in a string with the matching application emoji (stored under the name `X_`, e.g. `{U}` → emoji `U_`).
public
encapsulatedSymbolsToEmojis(string $subject) : string
Tokens with no matching emoji are left as-is.
Parameters
- $subject : string
-
Card text containing
{...}symbol tokens.
Tags
Return values
string —The text with known symbols replaced by emojis.