| Conditions | 6 |
| Paths | 5 |
| Total Lines | 17 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 38 | 173 | protected function addValidationClassToAttributes( |
|
| 39 | array &$attributes, |
||
| 40 | FormModelInterface $formModel, |
||
| 41 | string $attributeName, |
||
| 42 | ): void { |
||
| 43 | 173 | if (!$formModel->isValidated()) { |
|
| 44 | 141 | return; |
|
| 45 | } |
||
| 46 | |||
| 47 | 32 | $hasErrors = $formModel->getFormErrors()->hasErrors($attributeName); |
|
| 48 | |||
| 49 | 32 | if ($hasErrors && $this->invalidClass !== null) { |
|
| 50 | 2 | Html::addCssClass($attributes, $this->invalidClass); |
|
| 51 | } |
||
| 52 | |||
| 53 | 32 | if (!$hasErrors && $this->validClass !== null) { |
|
| 54 | 2 | Html::addCssClass($attributes, $this->validClass); |
|
| 55 | } |
||
| 58 |