Text
in package
FinalYes
Small pure text helpers for rendering Magic data into Discord messages.
Tags
Table of Contents
Constants
- FORMATS : array<string, string> = ['alchemy' => 'Alchemy', 'brawl' => 'Brawl', 'c...
- Friendly names for MTGJSON's format keys; anything else is title-cased.
- PROVIDERS : array<string, string> = ['tcgplayer' => 'TCGplayer', 'cardkingdom' => '...
- Friendly names for MTGJSON's price providers.
- RARITIES : array<string, string> = ['common' => '⚫', 'uncommon' => '⚪', 'rare' =>...
- Rarity symbols, in the colors of the set symbol.
Methods
- cardMentions() : array<string|int, array{name: string, set: ?string}>
- The card references in a message: `[[Name]]`, or `[[Name|SET]]` for a printing from one set. At most `$limit`, duplicates dropped.
- clip() : string
- Shortens text to a length, with an ellipsis when it was cut.
- format() : string
- A format's friendly name.
- money() : string
- A price with its currency symbol, e.g. `$0.63` or `€1.71`.
- plural() : string
- "1 card", "3 cards".
Constants
FORMATS
Friendly names for MTGJSON's format keys; anything else is title-cased.
public
array<string, string>
FORMATS
= ['alchemy' => 'Alchemy', 'brawl' => 'Brawl', 'commander' => 'Commander', 'competitivebrawl' => 'Competitive Brawl', 'duel' => 'Duel Commander', 'future' => 'Future Standard', 'gladiator' => 'Gladiator', 'historic' => 'Historic', 'legacy' => 'Legacy', 'modern' => 'Modern', 'oathbreaker' => 'Oathbreaker', 'oldschool' => 'Old School', 'pauper' => 'Pauper', 'paupercommander' => 'Pauper Commander', 'penny' => 'Penny Dreadful', 'pioneer' => 'Pioneer', 'predh' => 'PreDH', 'premodern' => 'Premodern', 'standard' => 'Standard', 'standardbrawl' => 'Standard Brawl', 'timeless' => 'Timeless', 'vintage' => 'Vintage']
PROVIDERS
Friendly names for MTGJSON's price providers.
public
array<string, string>
PROVIDERS
= ['tcgplayer' => 'TCGplayer', 'cardkingdom' => 'Card Kingdom', 'cardmarket' => 'Cardmarket', 'manapool' => 'Mana Pool', 'cardhoarder' => 'Cardhoarder (MTGO)']
RARITIES
Rarity symbols, in the colors of the set symbol.
public
array<string, string>
RARITIES
= ['common' => '⚫', 'uncommon' => '⚪', 'rare' => '🟡', 'mythic' => '🟠', 'special' => '🟣', 'bonus' => '🟣']
Methods
cardMentions()
The card references in a message: `[[Name]]`, or `[[Name|SET]]` for a printing from one set. At most `$limit`, duplicates dropped.
public
static cardMentions(string $content[, int $limit = 5 ]) : array<string|int, array{name: string, set: ?string}>
Parameters
- $content : string
- $limit : int = 5
Return values
array<string|int, array{name: string, set: ?string}>clip()
Shortens text to a length, with an ellipsis when it was cut.
public
static clip(string $text, int $length) : string
Parameters
- $text : string
- $length : int
-
Characters, including the ellipsis.
Return values
stringformat()
A format's friendly name.
public
static format(string $format) : string
Parameters
- $format : string
-
MTGJSON's key, e.g.
paupercommander.
Return values
stringmoney()
A price with its currency symbol, e.g. `$0.63` or `€1.71`.
public
static money(float $price, string|null $currency) : string
Parameters
- $price : float
- $currency : string|null
-
USD,EUR, …
Return values
stringplural()
"1 card", "3 cards".
public
static plural(int $count, string $singular[, string $plural = null ]) : string
Parameters
- $count : int
- $singular : string
- $plural : string = null
-
Defaults to the singular plus
s.