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