Skip to content

Api: HasMessages

Adrian edited this page Feb 28, 2024 · 3 revisions

at\peekaboo\HasMessages

An interface for objects that use/provide ICU messages.

instance methods

  • HasMessages::makeMessage()

    public makeMessage( string $key, array $context = [], string $locale = null ) : string
    
    Builds a message from the given key and context, if a matching format is found.
    • parameters:
      • string $key: Message identifier. This is a dot-delimited path for the message format to look up.
      • array $context: Formatting context, in key:value format. Non-scalar values will be encoded if possible.
      • string $locale: The locale to use for formatting. If omitted, uses the MessagyRegistry's default local.
    • Throws MessageException MessageError::NoMessages: If no matching message is found for the given key.
    • Throws MessageException MessageError::NotAMessage: If the given key is found but is not a formatting string.
    • Returns string: A formatted message on success.