Conditions | 7 |
Paths | 5 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 0 |
1 | <?php |
||
32 | public function validateAttribute($model, $attribute) |
||
33 | { |
||
34 | /** @var Model $model */ |
||
35 | $value = $model->$attribute; |
||
36 | |||
37 | if (!empty($value) && \is_object($value) && $value instanceof Model) { |
||
38 | /** @var Model $value */ |
||
39 | if (!$value->validate()) { |
||
40 | $errors = $value->getErrors(); |
||
41 | foreach ($errors as $attributeError => $valueErrors) { |
||
42 | /** @var array $valueErrors */ |
||
43 | foreach ($valueErrors as $valueError) { |
||
44 | $model->addError( |
||
45 | $attribute, |
||
46 | Craft::t('seomatic', 'Object failed to validate') |
||
47 | . '-' . $attributeError . ' - ' . $valueError |
||
48 | ); |
||
49 | } |
||
50 | } |
||
51 | } |
||
52 | } else { |
||
53 | $model->addError($attribute, Craft::t('seomatic', 'Is not a Model object.')); |
||
54 | } |
||
57 |