UpdateProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 48
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A populate() 0 7 1
A run() 0 4 1
A find() 0 7 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\UpdateRecord;
12
use flipbox\patron\records\Provider;
13
use yii\db\ActiveRecord;
14
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 1.0.0
18
 */
19
class UpdateProvider extends UpdateRecord
20
{
21
    use PopulateSettingsTrait;
22
23
    /**
24
     * @inheritdoc
25
     */
26
    public $validBodyParams = [
27
        'handle',
28
        'clientId',
29
        'clientSecret',
30
        'scopes',
31
        'class',
32
        'enabled'
33
    ];
34
35
    /**
36
     * @param ActiveRecord|Provider $record
37
     * @return ActiveRecord
38
     */
39
    protected function populate(ActiveRecord $record): ActiveRecord
40
    {
41
        parent::populate($record);
42
        $this->populateSettings($record);
43
44
        return $record;
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public function run($provider)
51
    {
52
        return parent::run($provider);
53
    }
54
55
    /**
56
     * @inheritdoc
57
     * @return Provider|null
58
     */
59
    protected function find($id)
60
    {
61
        return Provider::findOne([
62
            'enabled' => null,
63
            'id' => $id
64
        ]);
65
    }
66
}
67