Passed
Push — master ( b2168e...f1daef )
by Paweł
03:26
created

SaveModelTrait::saveModel()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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\db\ActiveRecord;
12
use yii\web\ServerErrorHttpException;
13
14
trait SaveModelTrait
15
{
16
    protected function saveModel(ActiveRecord $model)
17
    {
18
        if (!$model->save()) {
19
            \Yii::error($model->errors, __METHOD__);
20
            throw new ServerErrorHttpException('Something went wrong.');
21
        }
22
    }
23
}