Completed
Push — develop ( 72ec54...8ecd83 )
by Nate
02:28
created

Save   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
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 23
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A runInternal() 0 14 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\ember\actions\record\traits;
10
11
use flipbox\ember\actions\traits\Populate;
12
use yii\db\ActiveRecord;
13
14
/**
15
 * @method ActiveRecord populate(ActiveRecord $record)
16
 *
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
trait Save
21
{
22
    use Populate, Manage;
23
24
    /**
25
     * @inheritdoc
26
     * @param ActiveRecord $record
27
     */
28
    public function runInternal(ActiveRecord $record)
29
    {
30
        if (($access = $this->checkAccess($record)) !== true) {
31
            return $access;
32
        }
33
34
        if (!$this->performAction(
35
            $this->populate($record)
36
        )) {
37
            return $this->handleFailResponse($record);
38
        }
39
40
        return $this->handleSuccessResponse($record);
41
    }
42
}
43