Passed
Push — master ( 0602c9...8f96ba )
by Thierry
02:02
created

ConfigTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 48
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A newConfig() 0 3 1
A getConfigReader() 0 3 1
A getConfig() 0 3 1
A registerConfigs() 0 7 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Container\Traits;
4
5
use Jaxon\Utils\Config\Config;
6
use Jaxon\Utils\Config\Reader;
7
8
trait ConfigTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait ConfigTrait
Loading history...
9
{
10
    /**
11
     * Register the values into the container
12
     *
13
     * @return void
14
     */
15
    private function registerConfigs()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
16
    {
17
        $this->set(Config::class, function($c) {
0 ignored issues
show
Bug introduced by
It seems like set() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

17
        $this->/** @scrutinizer ignore-call */ 
18
               set(Config::class, function($c) {
Loading history...
18
            return new Config($c->g('jaxon.core.options'));
19
        });
20
        $this->set(Reader::class, function($c) {
21
            return new Reader($c->g(Config::class));
22
        });
23
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
24
25
    /**
26
     * Get the config manager
27
     *
28
     * @return Config
29
     */
30
    public function getConfig()
31
    {
32
        return $this->g(Config::class);
0 ignored issues
show
Bug introduced by
It seems like g() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

32
        return $this->/** @scrutinizer ignore-call */ g(Config::class);
Loading history...
33
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
34
35
    /**
36
     * Get the config reader
37
     *
38
     * @return Reader
39
     */
40
    public function getConfigReader()
41
    {
42
        return $this->g(Reader::class);
43
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
44
45
    /**
46
     * Create a new the config manager
47
     *
48
     * @param array             $aOptions           The options array
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 13 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 11 found
Loading history...
49
     * @param string            $sKeys              The keys of the options in the array
0 ignored issues
show
Coding Style introduced by
Expected 4 spaces after parameter name; 14 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 12 found
Loading history...
50
     *
51
     * @return Config            The config manager
52
     */
53
    public function newConfig(array $aOptions = [], $sKeys = '')
54
    {
55
        return new Config($aOptions, $sKeys);
56
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
57
}
58