You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
830 B
34 lines
830 B
<?php
|
|
|
|
namespace App\Models\Validation\Validators;
|
|
|
|
use App\Models\Validation\Validators\ValidationInterface;
|
|
use App\Models\Validation\Validators\ValidationTrait;
|
|
|
|
class UpperRangeValidator implements ValidationInterface {
|
|
private ValidationInterface $nextValidator;
|
|
private int $value;
|
|
private int $rangeLimit;
|
|
|
|
public function __construct(int $value, int $rangeLimit, ValidationInterface $nextValidator)
|
|
{
|
|
$this->value = $value;
|
|
$this->rangeLimit = $rangeLimit;
|
|
$this->nextValidator = $nextValidator;
|
|
}
|
|
|
|
public function isCurrentValid(): bool
|
|
{
|
|
if($this->value > $this->rangeLimit)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
public function isValid(): bool
|
|
{
|
|
return $this->isCurrentValid() && $this->nextValidator->isValid();
|
|
}
|
|
}
|
|
|