| Conditions | 4 |
| Paths | 6 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 3 | public function validateAttribute($model, $attribute) |
|
| 26 | { |
||
| 27 | 3 | $value = $model->$attribute; |
|
| 28 | 3 | if (!$value instanceof JsonField) { |
|
| 29 | try { |
||
| 30 | 3 | $new = new JsonField($value); |
|
| 31 | 3 | if ($this->merge) { |
|
| 32 | /** @var BaseActiveRecord $model */ |
||
| 33 | 1 | $old = new JsonField($model->getOldAttribute($attribute)); |
|
| 34 | 1 | $new = new JsonField(array_merge($old->toArray(), $new->toArray())); |
|
| 35 | 1 | } |
|
| 36 | 3 | $model->$attribute = $new; |
|
| 37 | 3 | } catch (InvalidParamException $e) { |
|
| 38 | 1 | $this->addError($model, $attribute, $this->getErrorMessage($e)); |
|
| 39 | 1 | $model->$attribute = new JsonField(); |
|
| 40 | } |
||
| 41 | 3 | } |
|
| 42 | 3 | } |
|
| 43 | |||
| 57 |