Completed
Push — develop ( b48ec5...ad5b3d )
by Nate
08:03
created

CacheHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
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 resolveCache() 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\hubspot\helpers;
10
11
use flipbox\hubspot\HubSpot;
12
use flipbox\hubspot\services\Cache;
13
use Psr\SimpleCache\CacheInterface;
14
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 1.0.0
18
 */
19
class CacheHelper
20
{
21
    /**
22
     * @param string|CacheInterface $cache
23
     * @return CacheInterface
24
     * @throws \yii\base\InvalidConfigException
25
     */
26
    public static function resolveCache($cache): CacheInterface
27
    {
28
        if ($cache instanceof CacheInterface) {
29
            return $cache;
30
        }
31
32
        if ($cache === null) {
33
            $cache = Cache::DEFAULT_CACHE;
34
        }
35
36
        return HubSpot::getInstance()->getCache()->get($cache);
37
    }
38
}
39