Conditions | 2 |
Paths | 1 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
32 | public static function createFromRule( |
||
33 | Rule $rule, |
||
34 | mixed $value = null, |
||
35 | ): self |
||
36 | { |
||
37 | 1 | $arg = $rule->getArgument(); |
|
38 | 1 | $printable = match (true) { |
|
39 | 1 | is_object($arg) => [get_class($arg)], |
|
|
|||
40 | 1 | is_callable($arg) => [get_debug_type($arg)], |
|
41 | 1 | default => (array) $arg, |
|
42 | }; |
||
43 | |||
44 | 1 | return new self( |
|
45 | 1 | $rule->getField(), |
|
46 | ( |
||
47 | 1 | $value |
|
48 | 1 | ? "'" . Strings::truncate(strval($value), 60) . "' is invalid value: " |
|
49 | 1 | : '' |
|
50 | 1 | ) . vsprintf($rule->getMessage(), $printable), |
|
51 | 1 | $rule->getCode(), |
|
52 | ); |
||
63 |