Text
in package
Helps with common text related tasks.
Tags
Table of Contents
Methods
- bold() : string
- Wrap text in HTML `<strong>` tags. Used for when variables in translations are bolded, since we want as little HTML in the translation strings as possible.
- embedSafe() : string
- renderEmojis() : string
- Replace emojis with their style equivalent.
- truncate() : string
- Truncates text.
Methods
bold()
Wrap text in HTML `<strong>` tags. Used for when variables in translations are bolded, since we want as little HTML in the translation strings as possible.
public
static bold(string $text) : string
Parameters
- $text : string
-
Text to wrap
Return values
string —Text wrapped in <strong>
tags
embedSafe()
public
static embedSafe(string|null $content) : string
Parameters
- $content : string|null
-
HTML content to use in Discord embed
Return values
string —HTML content with tags removed and newlines converted to Discord's linebreaks
renderEmojis()
Replace emojis with their style equivalent.
public
static renderEmojis(string $text[, string|null $force_style = null ]) : string
Parameters
- $text : string
-
Text to parse
- $force_style : string|null = null
-
Style to apply to the emoji image, will use the site default if null
Return values
string —Text with emojis replaced with URLs to their Twemoji equivalent.
truncate()
Truncates text.
public
static truncate(string $text[, int $length = 750 ][, array<string|int, mixed> $options = [] ]) : string
Cuts a string to the length of $length and replaces the last characters with the ending if the text is longer than length.
Options:
-
ending
Will be used as Ending and appended to the trimmed string -
exact
If false, $text will not be cut mid-word -
html
If true, HTML tags would be handled correctly
Parameters
- $text : string
-
String to truncate.
- $length : int = 750
-
Length of returned string, including ellipsis.
- $options : array<string|int, mixed> = []
-
An array of html attributes and options.
Tags
Return values
string —Trimmed string.