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

InteractsWithConfig   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 5
cts 10
cp 0.5
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0

2 Methods

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