@@ -35,14 +35,16 @@ |
||
| 35 | 35 | { |
| 36 | 36 | $result = (new StringType())->validate($data); |
| 37 | 37 | |
| 38 | - if (!$result->isValid()) |
|
| 39 | - return new $result; |
|
| 38 | + if (!$result->isValid()) { |
|
| 39 | + return new $result; |
|
| 40 | + } |
|
| 40 | 41 | |
| 41 | 42 | if (mb_strlen($data, 'UTF-8') == $this->length) { |
| 42 | 43 | return new Success(); |
| 43 | - } |
|
| 44 | - else return new Failure( |
|
| 44 | + } else { |
|
| 45 | + return new Failure( |
|
| 45 | 46 | new RuleError(RuleErrorCode::LENGTH_ERROR, |
| 46 | 47 | 'The supplied string is not of correct length')); |
| 48 | + } |
|
| 47 | 49 | } |
| 48 | 50 | } |
| 49 | 51 | \ No newline at end of file |
@@ -26,8 +26,9 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | public function __construct(Type $type) |
| 28 | 28 | { |
| 29 | - if (empty($type->getValue())) |
|
| 30 | - throw new EmptyRequiredValue('The required type '. get_class($type) . ' cannot have an empty value'); |
|
| 29 | + if (empty($type->getValue())) { |
|
| 30 | + throw new EmptyRequiredValue('The required type '. get_class($type) . ' cannot have an empty value'); |
|
| 31 | + } |
|
| 31 | 32 | |
| 32 | 33 | $this->type = $type; |
| 33 | 34 | } |