@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @var array $allowedChars |
| 37 | 37 | */ |
| 38 | - private $allowedChars = []; |
|
| 38 | + private $allowedChars = [ ]; |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * NameValidator constructor. |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param int $maxLength |
| 45 | 45 | * @param array $allowedChars |
| 46 | 46 | */ |
| 47 | - public function __construct(int $minLength = 1, int $maxLength = 255, $allowedChars = ["\'", "-", ".", " "]) |
|
| 47 | + public function __construct(int $minLength = 1, int $maxLength = 255, $allowedChars = [ "\'", "-", ".", " " ]) |
|
| 48 | 48 | { |
| 49 | 49 | $this->minLength = $minLength; |
| 50 | 50 | $this->maxLength = $maxLength; |
@@ -66,8 +66,9 @@ |
||
| 66 | 66 | |
| 67 | 67 | $result = $rule->validate($name); |
| 68 | 68 | |
| 69 | - if ($result->isValid()) |
|
| 70 | - return new Success(); |
|
| 69 | + if ($result->isValid()) { |
|
| 70 | + return new Success(); |
|
| 71 | + } |
|
| 71 | 72 | /** |
| 72 | 73 | * @var Failure $result |
| 73 | 74 | */ |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | * @param array|Error $errors |
| 27 | 27 | * @param int $code |
| 28 | 28 | */ |
| 29 | - public function __construct(string $message = "", $errors = [], int $code = 0) |
|
| 29 | + public function __construct(string $message = "", $errors = [ ], int $code = 0) |
|
| 30 | 30 | { |
| 31 | 31 | parent::__construct($message, $code); |
| 32 | 32 | $this->errors = $errors; |
@@ -36,11 +36,13 @@ |
||
| 36 | 36 | { |
| 37 | 37 | $numericResult = (new NumericType())->validate($value); |
| 38 | 38 | |
| 39 | - if (!$numericResult->isValid()) |
|
| 40 | - return new $numericResult; |
|
| 39 | + if (!$numericResult->isValid()) { |
|
| 40 | + return new $numericResult; |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | - if ($value == $this->expected) |
|
| 43 | - return new Success(); |
|
| 43 | + if ($value == $this->expected) { |
|
| 44 | + return new Success(); |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | return new Failure(new RuleError(RuleErrorCode::LESS_THAN_MINIMUM, |
| 46 | 48 | 'The supplied number is less than the expectedimum value')); |
@@ -36,11 +36,13 @@ |
||
| 36 | 36 | { |
| 37 | 37 | $numericResult = (new NumericType())->validate($value); |
| 38 | 38 | |
| 39 | - if (!$numericResult->isValid()) |
|
| 40 | - return new $numericResult; |
|
| 39 | + if (!$numericResult->isValid()) { |
|
| 40 | + return new $numericResult; |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | - if ($value >= $this->min) |
|
| 43 | - return new Success(); |
|
| 43 | + if ($value >= $this->min) { |
|
| 44 | + return new Success(); |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | return new Failure(new RuleError(RuleErrorCode::LESS_THAN_MINIMUM, |
| 46 | 48 | 'The supplied number is less than the minimum value')); |
@@ -27,11 +27,13 @@ |
||
| 27 | 27 | { |
| 28 | 28 | $numericResult = (new NumericType())->validate($value); |
| 29 | 29 | |
| 30 | - if (!$numericResult->isValid()) |
|
| 31 | - return new $numericResult; |
|
| 30 | + if (!$numericResult->isValid()) { |
|
| 31 | + return new $numericResult; |
|
| 32 | + } |
|
| 32 | 33 | |
| 33 | - if ($value < 0) |
|
| 34 | - return new Success(); |
|
| 34 | + if ($value < 0) { |
|
| 35 | + return new Success(); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | return new Failure(new RuleError(RuleErrorCode::NOT_NEGATIVE, 'The supplied number is not negative')); |
| 37 | 39 | } |
@@ -36,11 +36,13 @@ |
||
| 36 | 36 | { |
| 37 | 37 | $numericResult = (new NumericType())->validate($value); |
| 38 | 38 | |
| 39 | - if (!$numericResult->isValid()) |
|
| 40 | - return new $numericResult; |
|
| 39 | + if (!$numericResult->isValid()) { |
|
| 40 | + return new $numericResult; |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | - if ($value <= $this->max) |
|
| 43 | - return new Success(); |
|
| 43 | + if ($value <= $this->max) { |
|
| 44 | + return new Success(); |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | return new Failure(new RuleError(RuleErrorCode::EXCEEDS_MAXIMUM, 'The supplied number exceeds the maximum value')); |
| 46 | 48 | } |
@@ -27,11 +27,13 @@ |
||
| 27 | 27 | { |
| 28 | 28 | $numericResult = (new NumericType())->validate($value); |
| 29 | 29 | |
| 30 | - if (!$numericResult->isValid()) |
|
| 31 | - return new $numericResult; |
|
| 30 | + if (!$numericResult->isValid()) { |
|
| 31 | + return new $numericResult; |
|
| 32 | + } |
|
| 32 | 33 | |
| 33 | - if ($value > 0) |
|
| 34 | - return new Success(); |
|
| 34 | + if ($value > 0) { |
|
| 35 | + return new Success(); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | return new Failure(new RuleError(RuleErrorCode::NOT_POSITIVE, 'The supplied number is not positive')); |
| 37 | 39 | } |
@@ -22,9 +22,10 @@ |
||
| 22 | 22 | { |
| 23 | 23 | public function validate($data): Result |
| 24 | 24 | { |
| 25 | - if (is_string($data)) |
|
| 26 | - return new Success(); |
|
| 27 | - else |
|
| 28 | - return new Failure(new RuleError(RuleErrorCode::NOT_STRING, 'Input value is not a string')); |
|
| 25 | + if (is_string($data)) { |
|
| 26 | + return new Success(); |
|
| 27 | + } else { |
|
| 28 | + return new Failure(new RuleError(RuleErrorCode::NOT_STRING, 'Input value is not a string')); |
|
| 29 | + } |
|
| 29 | 30 | } |
| 30 | 31 | } |
| 31 | 32 | \ No newline at end of file |
@@ -23,9 +23,10 @@ |
||
| 23 | 23 | { |
| 24 | 24 | public function validate($data): Result |
| 25 | 25 | { |
| 26 | - if (is_numeric($data)) |
|
| 27 | - return new Success(); |
|
| 28 | - else |
|
| 29 | - return new Failure(new RuleError(RuleErrorCode::NOT_NUMERIC, 'Input value is not numeric')); |
|
| 26 | + if (is_numeric($data)) { |
|
| 27 | + return new Success(); |
|
| 28 | + } else { |
|
| 29 | + return new Failure(new RuleError(RuleErrorCode::NOT_NUMERIC, 'Input value is not numeric')); |
|
| 30 | + } |
|
| 30 | 31 | } |
| 31 | 32 | } |
| 32 | 33 | \ No newline at end of file |