Passed
Pull Request — master (#222)
by Dmitriy
12:29
created

Callback   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 92.31%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 34
ccs 12
cts 13
cp 0.9231
rs 10
c 1
b 0
f 0
wmc 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Rule;
6
7
use Closure;
8
use Yiisoft\Validator\Rule\Trait\RuleNameTrait;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_TRAIT, expecting T_STRING or '{' on line 8 at column 27
Loading history...
9
use Yiisoft\Validator\Rule\Trait\HandlerClassNameTrait;
10
use Yiisoft\Validator\RuleInterface;
11
12
final class Callback implements RuleInterface
13
{
14
    use HandlerClassNameTrait;
15
    use RuleNameTrait;
16
17 4
    public function __construct(
18
        /**
19
         * @var callable
20
         */
21
        public          $callback,
22
        public bool $skipOnEmpty = false,
23
        public bool $skipOnError = false,
24
        public ?Closure $when = null,
25
    ) {
26
    }
27
28 2
    public function getOptions(): array
29
    {
30
        return [
31 2
            'skipOnEmpty' => $this->skipOnEmpty,
32 2
            'skipOnError' => $this->skipOnError,
33
        ];
34
    }
35
}
36