Update the validation engine of the "When" rule

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2024-02-23 02:33:01 +01:00
parent 2c56575ce3
commit d184d9d95b
No known key found for this signature in database
GPG key ID: 221E9281655813A6

View file

@ -19,7 +19,7 @@ use Respect\Validation\Validatable;
'after asserting that',
'after failing to assert that',
)]
final class When extends AbstractRule
final class When extends Standard
{
use CanBindEvaluateRule;
@ -53,35 +53,4 @@ final class When extends AbstractRule
return $elseResult->withNextSibling($thisResult->withNextSibling($whenResult));
}
public function validate(mixed $input): bool
{
if ($this->when->validate($input)) {
return $this->then->validate($input);
}
return $this->else->validate($input);
}
public function assert(mixed $input): void
{
if ($this->when->validate($input)) {
$this->then->assert($input);
return;
}
$this->else->assert($input);
}
public function check(mixed $input): void
{
if ($this->when->validate($input)) {
$this->then->check($input);
return;
}
$this->else->check($input);
}
}