InteractsWithConfig::getConfigStore()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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
     * @param $name
13
     * @param null $default
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $default is correct as it would always require null to be passed?
Loading history...
14
     * @return array|null
15
     */
16
    protected function getConfigStore($name, $default = null)
0 ignored issues
show
Unused Code introduced by
The parameter $default is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

16
    protected function getConfigStore($name, /** @scrutinizer ignore-unused */ $default = null)

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

Loading history...
17 2
    {
18
        return $this->getConfig('stores.' . $name, $default = null);
19 2
    }
20
21
    /**
22
     * Get the filesystem connection configuration.
23
     *
24
     * @param string $name
25
     * @param null $default
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $default is correct as it would always require null to be passed?
Loading history...
26
     * @return array
27
     */
28
    protected function getConfig($name, $default = null)
29 1
    {
30
        if (!function_exists('config') || !function_exists('app')) {
31 1
            return $default;
32
        }
33
        try {
34
            $config = config();
35 1
        } catch (\Exception $e) {
36 1
            return $default;
37 1
        }
38
        $configName = "cache.{$name}";
39
        if (!$config->has($configName)) {
40
            return $default;
41
        }
42
43
        return $config->get($configName)->toArray();
44
    }
45
}
46