CacheTrait::resolveCache()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
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 Psr\SimpleCache\CacheInterface;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 1.0.0
17
 */
18
trait CacheTrait
19
{
20
    use \Flipbox\HubSpot\Criteria\CacheTrait;
21
22
    /**
23
     * @inheritdoc
24
     */
25
    protected function resolveCache($cache): CacheInterface
26
    {
27
        if ($cache instanceof CacheInterface) {
28
            return $cache;
29
        }
30
31
        if ($cache === null) {
32
            $cache = HubSpot::getInstance()->getSettings()->getDefaultCache();
33
        }
34
35
        return HubSpot::getInstance()->getCache()->get($cache);
36
    }
37
}
38