Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| MaxLength | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| validate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Sire\Rule; |
| 6 | |
| 7 | use Celemas\Sire\Contract; |
| 8 | use Celemas\Sire\Validation; |
| 9 | use Override; |
| 10 | |
| 11 | /** @api */ |
| 12 | final class MaxLength implements Contract\Rule |
| 13 | { |
| 14 | public string $message { |
| 15 | get => '{label} must be at most {arg1} characters'; |
| 16 | } |
| 17 | |
| 18 | #[Override] |
| 19 | public function validate(Contract\Value $value, string ...$args): Contract\Validation |
| 20 | { |
| 21 | return Validation::from(strlen($value->value) <= (int) ($args[0] ?? null)); |
| 22 | } |
| 23 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 15 | get => '{label} must be at most {arg1} characters'; |
| 19 | public function validate(Contract\Value $value, string ...$args): Contract\Validation |
| 20 | { |
| 21 | return Validation::from(strlen($value->value) <= (int) ($args[0] ?? null)); |
| 22 | } |