| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4.016 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 44 | 8 | public function isValid(AnnotatedInterface $model, $attribute) |
|
| 45 | { |
||
| 46 | 8 | if (!$this->whenValidate($model)) |
|
| 47 | { |
||
| 48 | return true; |
||
| 49 | } |
||
| 50 | 8 | $label = ManganMeta::create($model)->field($attribute)->label; |
|
| 51 | 8 | if (!is_array($model->$attribute)) |
|
| 52 | { |
||
| 53 | 2 | if (!$model->$attribute instanceof Countable) |
|
| 54 | { |
||
| 55 | 1 | $this->addError('msgInvalid', ['{attribute}' => $label]); |
|
| 56 | 1 | return false; |
|
| 57 | } |
||
| 58 | } |
||
| 59 | 7 | $value = count($model->$attribute); |
|
| 60 | 7 | return $this->isValidValueOf($model, $attribute, $value, $label); |
|
| 61 | } |
||
| 62 | |||
| 64 |