SaveModelTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 26
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A runInternal() 0 16 3
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipboxfactory/craft-ember/blob/master/LICENSE
6
 * @link       https://github.com/flipboxfactory/craft-ember/
7
 */
8
9
namespace flipbox\craft\ember\actions\models;
10
11
use flipbox\craft\ember\actions\PopulateTrait;
12
use yii\base\Model;
13
14
/**
15
 * @method Model populate(Model $model)
16
 *
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 2.0.0
19
 */
20
trait SaveModelTrait
21
{
22
    use PopulateTrait, ManageModelTrait;
23
24
    /**
25
     * @param Model $model
26
     * @return mixed
27
     * @throws \yii\web\UnauthorizedHttpException
28
     */
29
    public function runInternal(Model $model)
30
    {
31
        // Populate
32
        $this->populate($model);
33
34
        // Check access
35
        if (($access = $this->checkAccess($model)) !== true) {
36
            return $access;
37
        }
38
39
        if (!$this->performAction($model)) {
40
            return $this->handleFailResponse($model);
41
        }
42
43
        return $this->handleSuccessResponse($model);
44
    }
45
}
46