IntegrationConnectionTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveConnection() 0 12 3
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\criteria;
10
11
use flipbox\craft\hubspot\HubSpot;
12
use Flipbox\HubSpot\Connections\ConnectionInterface;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 1.0.0
17
 */
18
trait IntegrationConnectionTrait
19
{
20
    use \Flipbox\HubSpot\Criteria\IntegrationConnectionTrait;
21
22
    /**
23
     * @param $connection
24
     * @return ConnectionInterface
25
     * @throws \flipbox\craft\integration\exceptions\ConnectionNotFound
26
     */
27
    protected static function resolveConnection($connection): ConnectionInterface
28
    {
29
        if ($connection instanceof ConnectionInterface) {
30
            return $connection;
31
        }
32
33
        if ($connection === null) {
34
            $connection = HubSpot::getInstance()->getSettings()->getDefaultIntegrationConnection();
35
        }
36
37
        return HubSpot::getInstance()->getConnections()->getIntegration($connection);
38
    }
39
}
40