Completed
Push — develop ( 11971b...45f15f )
by Nate
06:59
created

CreateElement::statusCodeSuccess()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
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 yii\base\Action;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 2.0.0
17
 */
18
abstract class CreateElement extends Action
19
{
20
    use SaveElementTrait;
21
22
    /**
23
     * @inheritdoc
24
     * @return ElementInterface
25
     */
26
    abstract protected function newElement(array $config = []): ElementInterface;
27
28
    /**
29
     * @inheritdoc
30
     * @return ElementInterface
31
     * @throws \Throwable
32
     * @throws \craft\errors\ElementNotFoundException
33
     * @throws \yii\base\Exception
34
     * @throws \yii\web\HttpException
35
     * @throws \yii\web\UnauthorizedHttpException
36
     */
37
    public function run()
38
    {
39
        return $this->runInternal($this->newElement());
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    public function statusCodeSuccess(): int
46
    {
47
        return $this->statusCodeSuccess ?: 201;
48
    }
49
}
50