ConfigManager   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 77
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A setApp() 0 3 1
A set() 0 3 1
A contains() 0 5 2
A __construct() 0 3 1
A getApp() 0 3 1
1
<?php
2
3
namespace Trucker\Support;
4
5
use Illuminate\Container\Container;
6
7
class ConfigManager
8
{
9
    /**
10
     * The IoC Container.
11
     *
12
     * @var Container
13
     */
14
    protected $app;
15
16
    /**
17
     * Build a new ConfigManager.
18
     *
19
     * @param Container $app
20
     */
21 6
    public function __construct(Container $app)
22
    {
23 6
        $this->app = $app;
24 6
    }
25
26
    /**
27
     * Getter to access the IoC Container.
28
     *
29
     * @return Container
30
     */
31 2
    public function getApp()
32
    {
33 2
        return $this->app;
34
    }
35
36
    /**
37
     * Setter for the IoC Container.
38
     *
39
     * @param Container
40
     */
41 48
    public function setApp($app)
42
    {
43 48
        $this->app = $app;
44 48
    }
45
46
    /**
47
     * Get an option from the config file.
48
     *
49
     * @param string $option
50
     *
51
     * @return mixed
52
     */
53 88
    public function get($option)
54
    {
55 88
        return $this->app['config']->get('trucker::' . $option);
0 ignored issues
show
Bug introduced by
The method get() does not exist on Illuminate\Support\Facades\Config. ( Ignorable by Annotation )

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

55
        return $this->app['config']->/** @scrutinizer ignore-call */ get('trucker::' . $option);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
    }
57
58
    /**
59
     * Set an option to the config file.
60
     *
61
     * @param string $option
62
     * @param mixed  $value
63
     *
64
     * @return mixed
65
     */
66 1
    public function set($option, $value)
67
    {
68 1
        return $this->app['config']->set('trucker::' . $option, $value);
0 ignored issues
show
Bug introduced by
The method set() does not exist on Illuminate\Support\Facades\Config. ( Ignorable by Annotation )

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

68
        return $this->app['config']->/** @scrutinizer ignore-call */ set('trucker::' . $option, $value);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
69
    }
70
71
    /**
72
     * Determine if a config option contains a specific.
73
     *
74
     * @param string $option Config value must be an array
75
     * @param mixed  $value
76
     *
77
     * @return bool
78
     */
79 5
    public function contains($option, $value)
80
    {
81 5
        $option = $this->get($option);
82
83 5
        return is_array($option) && in_array($value, $option, true);
84
    }
85
}
86