Completed
Push — master ( 19b2ae...0e0de4 )
by Nate
04:43
created

DisableProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 36
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 4 1
A find() 0 8 1
A performAction() 0 5 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/patron/license
6
 * @link       https://www.flipboxfactory.com/software/patron/
7
 */
8
9
namespace flipbox\patron\actions\provider;
10
11
use flipbox\craft\ember\actions\records\LookupRecordTrait;
12
use flipbox\craft\ember\actions\records\ManageRecordTrait;
13
use flipbox\patron\records\Provider;
14
use yii\base\Action;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
class DisableProvider extends Action
21
{
22
    use ManageRecordTrait, LookupRecordTrait {
23
        run as traitRun;
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function run($provider)
30
    {
31
        return $this->traitRun($provider);
32
    }
33
34
    /**
35
     * @inheritdoc
36
     * @return Provider|null
37
     */
38
    protected function find($id)
39
    {
40
        return Provider::findOne([
41
            'enabled' => null,
42
            'environment' => null,
43
            'id' => $id
44
        ]);
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    protected function performAction(Provider $record): bool
51
    {
52
        $record->enabled = false;
53
        return $record->save(true, ['enabled']);
54
    }
55
}
56