| Conditions | 5 |
| Paths | 8 |
| Total Lines | 25 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5.0187 |
| Changes | 0 | ||
| 1 | <?php |
||
| 62 | 3 | public function isValid(Language $language, $break_when_error = false) : bool |
|
| 63 | { |
||
| 64 | /** @var \PluginSimpleValidate\Contracts\Rule $rule */ |
||
| 65 | 3 | foreach ($this->rules as $ruleName => $rule) { |
|
| 66 | 3 | if (!$rule->isValid($language, $this->value)) { |
|
| 67 | 3 | $this->status = false; |
|
| 68 | 3 | $this->errors[] = $language->getTranslation( |
|
| 69 | 3 | $rule->getLangKey() |
|
| 70 | ); |
||
| 71 | |||
| 72 | /** |
||
| 73 | * break when there is any rule error |
||
| 74 | */ |
||
| 75 | 3 | if ($break_when_error === true) { |
|
| 76 | 3 | break; |
|
| 77 | } |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | 3 | if (empty($this->errors)) { |
|
| 82 | $this->status = true; |
||
| 83 | } |
||
| 84 | |||
| 85 | 3 | return $this->status; |
|
| 86 | } |
||
| 87 | |||
| 137 | } |