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

CreateElement   A

Complexity

Total Complexity 3

Size/Duplication

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
newElement() 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\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