| Total Complexity | 8 |
| Total Lines | 82 |
| Duplicated Lines | 0 % |
| Coverage | 90.48% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] |
||
| 22 | final class AtLeast implements SerializableRuleInterface, SkipOnErrorInterface, WhenInterface, SkipOnEmptyInterface |
||
| 23 | { |
||
| 24 | use SkipOnEmptyTrait; |
||
| 25 | use SkipOnErrorTrait; |
||
| 26 | use WhenTrait; |
||
| 27 | |||
| 28 | 3 | public function __construct( |
|
| 29 | /** |
||
| 30 | * @var string[] The list of required attributes that will be checked. |
||
| 31 | */ |
||
| 32 | private array $attributes, |
||
| 33 | /** |
||
| 34 | * @var int The minimum required quantity of filled attributes to pass the validation. Defaults to 1. |
||
| 35 | */ |
||
| 36 | private int $min = 1, |
||
| 37 | private string $incorrectInputMessage = 'Value must be an array or an object.', |
||
| 38 | /** |
||
| 39 | * @var string Message to display in case of error. |
||
| 40 | */ |
||
| 41 | private string $message = 'The model is not valid. Must have at least "{min}" filled attributes.', |
||
| 42 | /** |
||
| 43 | * @var bool|callable|null |
||
| 44 | */ |
||
| 45 | private mixed $skipOnEmpty = null, |
||
| 46 | /** |
||
| 47 | * @var bool |
||
| 48 | */ |
||
| 49 | private bool $skipOnError = false, |
||
| 50 | /** |
||
| 51 | * @var Closure(mixed, ValidationContext):bool|null |
||
| 52 | */ |
||
| 53 | private ?Closure $when = null |
||
| 54 | ) { |
||
| 55 | } |
||
| 56 | |||
| 57 | 1 | public function getName(): string |
|
| 58 | { |
||
| 59 | 1 | return 'atLeast'; |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return string[] |
||
| 64 | */ |
||
| 65 | 11 | public function getAttributes(): array |
|
| 66 | { |
||
| 67 | 11 | return $this->attributes; |
|
| 68 | } |
||
| 69 | |||
| 70 | 11 | public function getMin(): int |
|
| 71 | { |
||
| 72 | 11 | return $this->min; |
|
| 73 | } |
||
| 74 | |||
| 75 | public function getIncorrectInputMessage(): string |
||
| 76 | { |
||
| 77 | return $this->incorrectInputMessage; |
||
| 78 | } |
||
| 79 | |||
| 80 | 3 | public function getMessage(): string |
|
| 83 | } |
||
| 84 | |||
| 85 | 2 | public function getOptions(): array |
|
| 97 | ]; |
||
| 98 | } |
||
| 99 | |||
| 100 | 11 | public function getHandlerClassName(): string |
|
| 103 | } |
||
| 104 | } |
||
| 105 |