Total Complexity | 11 |
Total Lines | 64 |
Duplicated Lines | 0 % |
Coverage | 88.89% |
Changes | 0 |
1 | <?php |
||
20 | use RuleNameTrait; |
||
21 | |||
22 | 1 | public function __construct( |
|
23 | /** |
||
24 | * @var iterable<RuleInterface> |
||
25 | */ |
||
26 | public iterable $rules = [], |
||
27 | public string $incorrectInputMessage = 'Value should be array or iterable.', |
||
28 | public string $message = '{error} {value} given.', |
||
29 | public bool $skipOnEmpty = false, |
||
30 | public bool $skipOnError = false, |
||
31 | public ?Closure $when = null, |
||
32 | ) { |
||
33 | } |
||
34 | |||
35 | 1 | public function getOptions(): array |
|
36 | { |
||
37 | 1 | $arrayOfRules = []; |
|
38 | 1 | foreach ($this->rules as $rule) { |
|
39 | 1 | if ($rule instanceof RuleInterface) { |
|
40 | 1 | $arrayOfRules[] = array_merge([$rule->getName()], $rule->getOptions()); |
|
41 | } else { |
||
42 | $arrayOfRules[] = [get_class($rule)]; |
||
43 | } |
||
44 | } |
||
45 | 1 | return $arrayOfRules; |
|
46 | } |
||
47 | } |
||
48 |