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

InteractsWithConfig   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 58.33%

Importance

Changes 0
Metric Value
dl 0
loc 38
ccs 7
cts 12
cp 0.5833
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigStore() 0 4 1
A getConfig() 0 17 5
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