Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
7 / 7
11.11% covered (danger)
11.11%
1 / 9
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Messages
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
7 / 7
11.11% covered (danger)
11.11%
1 / 9
100.00% covered (success)
100.00%
1 / 1
9.32
100.00% covered (success)
100.00%
1 / 1
 defaults
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
7 / 7
11.11% covered (danger)
11.11%
1 / 9
100.00% covered (success)
100.00%
1 / 1
9.32
1<?php
2
3declare(strict_types=1);
4
5namespace Celema\Sire;
6
7/** @internal */
8final class Messages
9{
10    public const string EXTRA = 'Field "{field}" is not allowed';
11    public const string MISSING = '{label} is required';
12    public const string NULL = '{label} must not be null';
13    public const string SHAPE = '{label} must be an array';
14
15    /** @return array<string, string> Every message key with its default template, sorted by key. */
16    public static function defaults(Contract\RuleRegistry $rules, Contract\CoercerRegistry $coercers): array
17    {
18        $messages = [
19            'extra' => self::EXTRA,
20            'missing' => self::MISSING,
21            'null' => self::NULL,
22            'type.shape' => self::SHAPE,
23        ];
24
25        foreach ($coercers->all() as $name => $coercer) {
26            $messages['type.' . $name] = $coercer->message;
27        }
28
29        foreach ($rules->all() as $name => $rule) {
30            $messages['rule.' . $name] = $rule->message;
31        }
32
33        ksort($messages, SORT_STRING);
34
35        return $messages;
36    }
37}

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

Messages->defaults
16    public static function defaults(Contract\RuleRegistry $rules, Contract\CoercerRegistry $coercers): array
17    {
18        $messages = [
19            'extra' => self::EXTRA,
20            'missing' => self::MISSING,
21            'null' => self::NULL,
22            'type.shape' => self::SHAPE,
23        ];
24
25        foreach ($coercers->all() as $name => $coercer) {
25        foreach ($coercers->all() as $name => $coercer) {
25        foreach ($coercers->all() as $name => $coercer) {
25        foreach ($coercers->all() as $name => $coercer) {
26            $messages['type.' . $name] = $coercer->message;
27        }
28
29        foreach ($rules->all() as $name => $rule) {
29        foreach ($rules->all() as $name => $rule) {
29        foreach ($rules->all() as $name => $rule) {
29        foreach ($rules->all() as $name => $rule) {
30            $messages['rule.' . $name] = $rule->message;
31        }
32
33        ksort($messages, SORT_STRING);
34
35        return $messages;
36    }