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

Save::runInternal()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 12
cp 0
rs 9.4285
c 0
b 0
f 0
nc 3
cc 3
eloc 7
nop 1
crap 12
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