Completed
Push — develop ( 2d4f17...d5975b )
by Nate
05:25
created

PopulateConnectionTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 20
ccs 0
cts 10
cp 0
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/hubspot/license
6
 * @link       https://www.flipboxfactory.com/software/hubspot/
7
 */
8
9
namespace flipbox\craft\hubspot\actions\connections;
10
11
use Craft;
12
use flipbox\craft\hubspot\records\Connection;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 1.0.0
17
 */
18
trait PopulateConnectionTrait
19
{
20
    /**
21
     * @param Connection $record
22
     * @return Connection
23
     */
24
    protected function populateSettings(Connection $record): Connection
25
    {
26
        $allSettings = Craft::$app->getRequest()->getBodyParam('settings');
27
28
        if (!is_array($allSettings)) {
29
            $allSettings = [$allSettings];
30
        }
31
32
        $settings = $allSettings[$record->class] ?? null;
33
        $record->settings = $settings;
34
35
        return $record;
36
    }
37
}
38