Test Setup Failed
Push — master ( 562b48...254002 )
by Gabriel
04:15 queued 14s
created

InteractsWithConfig::getConfig()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 7.9062

Importance

Changes 0
Metric Value
cc 4
nc 3
nop 2
dl 0
loc 14
ccs 3
cts 8
cp 0.375
crap 7.9062
rs 9.7998
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 1
            return $default;
33
        }
34
        /** @noinspection PhpUnhandledExceptionInspection */
35
        $config = config();
36
        $configName = "cache.{$name}";
37
        if (!$config->has($configName)) {
38
            return $default;
39
        }
40
41
        return $config->get($configName)->toArray();
42
    }
43
}
44