PluginOption::getFile()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 2 Features 0
Metric Value
c 3
b 2
f 0
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 1
1
<?php namespace Mascame\Artificer\Options;
2
3
use Config;
4
5
class PluginOption
6
{
7
8
    /**
9
     * @var string
10
     */
11
    public $namespace;
12
13
    /**
14
     * @var string
15
     */
16
    public $configFile;
17
18
    /**
19
     * @param $namespace
20
     */
21
    public function __construct($namespace, $configFile)
22
    {
23
        $exploded_namespace = explode('/', $namespace);
24
        $this->namespace = end($exploded_namespace) . '::';
25
        $this->configFile = $configFile;
26
    }
27
28
    /**
29
     * @param string $plugin
0 ignored issues
show
Bug introduced by
There is no parameter named $plugin. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
30
     * @param string $key
31
     */
32
    public function get($key = null, $configFile = null)
33
    {
34
        return Config::get($this->getPrefix($configFile) . $key);
35
    }
36
37
    /**
38
     * @param string $plugin
0 ignored issues
show
Bug introduced by
There is no parameter named $plugin. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
39
     */
40
    public function has($key = '', $configFile = null)
41
    {
42
        return Config::has($this->getPrefix($configFile) . $key);
43
    }
44
45
    /**
46
     * @param string $plugin
0 ignored issues
show
Bug introduced by
There is no parameter named $plugin. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
47
     */
48
    public function set($key, $value, $configFile = null)
49
    {
50
        Config::set($this->getPrefix($configFile) . $key, $value);
51
    }
52
53
    /**
54
     * @param string $key
55
     */
56
    public function all($key = null, $configFile = null)
57
    {
58
        return Config::get($this->getPrefix($configFile) . $key);
59
    }
60
61
    /**
62
     * @param null $configFile
63
     * @return null|string
64
     */
65
    protected function getFile($configFile = null)
66
    {
67
        return ($configFile) ? $configFile : $this->configFile;
68
    }
69
70
    /**
71
     * @param $file
72
     */
73
    public function setConfigFile($file)
74
    {
75
        $this->configFile = $file;
76
    }
77
78
    public function getPrefix($configFile = null)
79
    {
80
        return $this->namespace . $this->getFile($configFile) . '.';
81
    }
82
}