Completed
Push — master ( 87f5f3...5d6f7d )
by Nate
03:14
created

PopulateSettingsTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A populateSettings() 0 13 2
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 Craft;
12
use flipbox\patron\records\Provider;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 2.1.0
17
 */
18
trait PopulateSettingsTrait
19
{
20
    /**
21
     * @param Provider $record
22
     * @return Provider
23
     */
24
    protected function populateSettings(Provider $record): Provider
25
    {
26
        $allSettings = Craft::$app->getRequest()->getBodyParam('settings');
27
28
        if (!is_array($allSettings)) {
29
            $allSettings = [$allSettings];
30
        }
31
32
        $record->settings = $allSettings[$record->class] ?? null;
33
        ;
34
35
        return $record;
36
    }
37
}
38