ConfigAwareTrait   A
last analyzed

↳ Parent: Project

Coupling/Cohesion

Components 1
Dependencies 2

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 42
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setConfig() 0 4 2
A getConfig() 0 4 1
A prepareConfig() 0 7 1
1
<?php
2
3
namespace League\Flysystem;
4
5
/**
6
 * @internal
7
 */
8
trait ConfigAwareTrait
9
{
10
    /**
11
     * @var Config
12
     */
13
    protected $config;
14
15
    /**
16
     * Set the config.
17
     *
18
     * @param Config|array|null $config
19
     */
20 234
    protected function setConfig($config)
21
    {
22 234
        $this->config = $config ? Util::ensureConfig($config) : new Config;
23 234
    }
24
25
    /**
26
     * Get the Config.
27
     *
28
     * @return Config config object
29
     */
30 60
    public function getConfig()
31
    {
32 60
        return $this->config;
33
    }
34
35
    /**
36
     * Convert a config array to a Config object with the correct fallback.
37
     *
38
     * @param array $config
39
     *
40
     * @return Config
41
     */
42 57
    protected function prepareConfig(array $config)
43
    {
44 57
        $config = new Config($config);
45 57
        $config->setFallback($this->getConfig());
46
47 57
        return $config;
48
    }
49
}
50