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

RecordCreate::newRecord()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
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