Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3namespace Wikimedia\NormalizedException;
4
5/**
6 * Interface for exceptions whose error message supports PSR-3 style placeholders.
7 * This allows extracting variable parts of the error message, so that the
8 * remaining normalized message can be used for better grouping of related errors
9 * in the logs.
10 *
11 * E.g. an exception message `User 'Foo' not found` could be normalized into
12 * `User '{user}' not found`, with `[ 'user' => 'Foo' ]` as context data.
13 *
14 * @stable to implement
15 */
16interface INormalizedException {
17
18    /**
19     * Returns a normalized version of the error message, with PSR-3 style placeholders.
20     * After replacing the placeholders with their values from the context data, the
21     * result should be equal to getMessage().
22     *
23     * @return string
24     */
25    public function getNormalizedMessage(): string;
26
27    /**
28     * Returns the context data. All placeholders in the normalized message must have a
29     * matching field in the array. Extra fields are allowed. Keys should match
30     * `/[a-zA-Z0-9_.]+/`, as per the PSR-3 spec. Values should be scalars.
31     *
32     * @return (int|float|string|bool)[]
33     */
34    public function getMessageContext(): array;
35
36}