Completed
Push — master ( 788ed8...3bee19 )
by Sebastian
03:13
created

Options   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 34
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 4 2
A getAll() 0 4 1
1
<?php
2
/**
3
 * This file is part of CaptainHook.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace sebastianfeldmann\CaptainHook\Config;
11
12
/**
13
 * Class Options
14
 *
15
 * @package CaptainHook
16
 * @author  Sebastian Feldmann <[email protected]>
17
 * @link    https://github.com/sebastianfeldmann/captainhook
18
 * @since   Class available since Release 1.0.0
19
 */
20
class Options
21
{
22
    /**
23
     * Options constructor.
24
     *
25
     * @param array $options
26
     */
27 26
    public function __construct(array $options)
28
    {
29 26
        $this->options = $options;
0 ignored issues
show
Bug introduced by
The property options does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
30 26
    }
31
32
    /**
33
     * Return a option value.
34
     *
35
     * @param  string $name
36
     * @param  mixed  $default
37
     * @return mixed
38
     */
39 6
    public function get($name, $default = null)
40
    {
41 6
        return isset($this->options[$name]) ? $this->options[$name] : $default;
42
    }
43
44
    /**
45
     * Return all options.
46
     *
47
     * @return array
48
     */
49 8
    public function getAll()
50
    {
51 8
        return $this->options;
52
    }
53
}
54