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

SaveModelTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A saveModel() 0 5 2
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
}