Update Validators to extend ABC instead of implementing interface.
This commit is contained in:
@@ -2,9 +2,14 @@
|
||||
|
||||
namespace App\Models\Validation\Validators;
|
||||
|
||||
use App\Models\Validation\Validators\ValidationInterface;
|
||||
use App\Models\Validation\Validators\Validator;
|
||||
|
||||
class OkValidator extends Validator {
|
||||
public function isCurrentValid(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
class OkValidator implements ValidationInterface {
|
||||
public function isValid(): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace App\Models\Validation\Validators;
|
||||
|
||||
use App\Models\Validation\Validators\ValidationInterface;
|
||||
use App\Models\Validation\Validators\ValidationTrait;
|
||||
use App\Models\Validation\Validators\Validator;
|
||||
|
||||
class UpperRangeValidator implements ValidationInterface {
|
||||
private ValidationInterface $nextValidator;
|
||||
class UpperRangeValidator extends Validator {
|
||||
private int $value;
|
||||
private int $rangeLimit;
|
||||
protected Validator $nextValidator;
|
||||
|
||||
public function __construct(int $value, int $rangeLimit, ValidationInterface $nextValidator)
|
||||
public function __construct(int $value, int $rangeLimit, Validator $nextValidator)
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->rangeLimit = $rangeLimit;
|
||||
@@ -24,10 +23,5 @@ class UpperRangeValidator implements ValidationInterface {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
return $this->isCurrentValid() && $this->nextValidator->isValid();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Validation\Validators;
|
||||
|
||||
abstract class Validator {
|
||||
abstract public function isCurrentValid(): bool;
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
return $this->isCurrentValid() && $this->nextValidator->isValid();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user