SaveModelTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
rs 10
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;
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
}