Test Setup Failed
Push — master ( 90378d...afbbde )
by Gabriel
06:45
created

InteractsWithConfig::getConfig()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 8.125

Importance

Changes 0
Metric Value
cc 5
nc 4
nop 2
dl 0
loc 17
ccs 5
cts 10
cp 0.5
crap 8.125
rs 9.3888
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Cache\CacheManager;
4
5
/**
6
 * Trait InteractsWithConfig
7
 * @package Nip\Cache\CacheManager
8
 */
9
trait InteractsWithConfig
10
{
11
12
    /**
13
     * @param $name
14
     * @param null $default
15
     * @return array|null
16
     */
17 2
    protected function getConfigStore($name, $default = null)
0 ignored issues
show
Unused Code introduced by
The parameter $default is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
18
    {
19 2
        return $this->getConfig('stores.' . $name, $default = null);
20
    }
21
22
    /**
23
     * Get the filesystem connection configuration.
24
     *
25
     * @param string $name
26
     * @param null $default
27
     * @return array
28
     */
29 1
    protected function getConfig($name, $default = null)
30
    {
31 1
        if (!function_exists('config') || !function_exists('app')) {
32
            return $default;
33
        }
34
        try {
35 1
            $config = config();
36 1
        } catch (\Exception $e) {
37 1
            return $default;
38
        }
39
        $configName = "cache.{$name}";
40
        if (!$config->has($configName)) {
41
            return $default;
42
        }
43
44
        return $config->get($configName)->toArray();
45
    }
46
}
47