Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Allowed
100.00% covered (success)
100.00%
2 / 2
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
1.12
100.00% covered (success)
100.00%
1 / 1
 validate
100.00% covered (success)
100.00%
2 / 2
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
1.12
1<?php
2
3declare(strict_types=1);
4
5namespace Celemas\Sire\Rule;
6
7use Celemas\Sire\Contract;
8use Celemas\Sire\DslSplitter;
9use Celemas\Sire\Validation;
10use Override;
11
12/** @api */
13final class Allowed implements Contract\Rule
14{
15    public string $message {
16        get => '{label} must be an allowed value';
17    }
18
19    #[Override]
20    public function validate(Contract\Value $value, string ...$args): Contract\Validation
21    {
22        $allowed = DslSplitter::split($args[0] ?? '', ',');
23
24        return Validation::from(in_array($value->value, $allowed, true));
25    }
26}

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.

Allowed->$message::get
16        get => '{label} must be an allowed value';
Allowed->validate
20    public function validate(Contract\Value $value, string ...$args): Contract\Validation
21    {
22        $allowed = DslSplitter::split($args[0] ?? '', ',');
23
24        return Validation::from(in_array($value->value, $allowed, true));
24        return Validation::from(in_array($value->value, $allowed, true));
24        return Validation::from(in_array($value->value, $allowed, true));
24        return Validation::from(in_array($value->value, $allowed, true));
25    }