Skip to content
PHP Ecosystem
Explore

MessageTemplate

API reference › Scaffold › MessageTemplate

traitPHPForge\Scaffold\MessageTemplate
Sourcesrc/MessageTemplate.php
Used by 2 types

Formats the sprintf template held by the backing value of a message enum case.

MethodDescriptionDefined by
getMessage()Returns the message template formatted with $argument.MessageTemplate
plural() staticReturns the text of $one when $count is 1, and the text of $many otherwise.MessageTemplate
public function getMessage(int|string ...$argument): string

Returns the message template formatted with $argument.

Parameters

ParameterTypeDescription
...$argumentint|stringValues substituted into the template.

Returns

string: Formatted message.

public static function plural(int $count, self $one, self $many): string

Returns the text of $one when $count is 1, and the text of $many otherwise.

Parameters

ParameterTypeDescription
$countintNumber of items the fragment counts.
$oneselfFragment for a single item.
$manyselfFragment for zero or several items.

Returns

string: Text of the fragment that agrees with $count.