Completed
Push — master ( 72ec54...05d808 )
by Nate
06:35 queued 04:36
created

RecordCreate   A

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 8
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
newRecord() 0 1 ?
A run() 0 4 1
A statusCodeSuccess() 0 4 2
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;
10
11
use yii\base\Action;
12
use yii\db\ActiveRecord;
13
use yii\web\Response;
14
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 1.0.0
18
 */
19
abstract class RecordCreate extends Action
20
{
21
    use traits\Save;
22
23
    /**
24
     * @param array $config
25
     * @return ActiveRecord
26
     */
27
    abstract protected function newRecord(array $config = []): ActiveRecord;
28
29
    /**
30
     * @return ActiveRecord|null|Response
31
     */
32
    public function run()
33
    {
34
        return $this->runInternal($this->newRecord());
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function statusCodeSuccess(): int
41
    {
42
        return $this->statusCodeSuccess ?: 201;
43
    }
44
}
45