Completed
Push — master ( 11971b...eeafb3 )
by Nate
01:16
created

DeleteElementTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 22
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A statusCodeSuccess() 0 4 1
A performAction() 0 4 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\craft\ember\actions\elements;
10
11
use Craft;
12
use craft\base\ElementInterface;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 2.0.0
17
 *
18
 * @property int $statusCodeSuccess
19
 */
20
trait DeleteElementTrait
21
{
22
    use ManageElementTrait;
23
24
    /**
25
     * @inheritdoc
26
     */
27
    protected function statusCodeSuccess(): int
28
    {
29
        return $this->statusCodeSuccess ?? 204;
30
    }
31
32
    /**
33
     * @inheritdoc
34
     * @param ElementInterface $element
35
     * @throws \Throwable
36
     */
37
    protected function performAction(ElementInterface $element): bool
38
    {
39
        return Craft::$app->getElements()->deleteElement($element);
40
    }
41
}
42