SaveElementTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
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 27
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\elements;
10
11
use craft\base\ElementInterface;
12
use flipbox\craft\ember\actions\PopulateTrait;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 2.0.0
17
 *
18
 * @method ElementInterface populate(ElementInterface $object);
19
 */
20
trait SaveElementTrait
21
{
22
    use PopulateTrait, ManageElementTrait;
23
24
    /**
25
     * @inheritdoc
26
     * @param ElementInterface $element
27
     * @throws \yii\base\Exception
28
     * @throws \yii\web\UnauthorizedHttpException
29
     */
30
    public function runInternal(ElementInterface $element)
31
    {
32
        // Populate
33
        $this->populate($element);
34
35
        // Check access
36
        if (($access = $this->checkAccess($element)) !== true) {
37
            return $access;
38
        }
39
40
        if (!$this->performAction($element)) {
41
            return $this->handleFailResponse($element);
42
        }
43
44
        return $this->handleSuccessResponse($element);
45
    }
46
}
47