SaveModelTrait::saveModel()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
rs 10
1
<?php
2
/**
3
 * Created for IG Monitoring.
4
 * User: jakim <[email protected]>
5
 * Date: 09.07.2018
6
 */
7
8
namespace app\components\traits;
9
10
11
use Yii;
12
use yii\db\ActiveRecord;
13
use yii\web\ServerErrorHttpException;
14
15
trait SaveModelTrait
16
{
17
    protected function saveModel(ActiveRecord $model)
18
    {
19
        if (!$model->save()) {
20
            Yii::error($model->errors, __METHOD__);
21
            throw new ServerErrorHttpException('Something went wrong.');
22
        }
23
    }
24
}