Completed
Push — master ( aa9657...bb9832 )
by Sebastian
05:21
created

Options   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 41
c 0
b 0
f 0
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
     * Map of options
24
     *
25
     * @var array
26
     */
27
    private $options;
28
29
    /**
30
     * Options constructor.
31
     *
32
     * @param array $options
33
     */
34 34
    public function __construct(array $options)
35
    {
36 34
        $this->options = $options;
37 34
    }
38
39
    /**
40
     * Return a option value.
41
     *
42
     * @param  string $name
43
     * @param  mixed  $default
44
     * @return mixed
45
     */
46 12
    public function get(string $name, $default = null)
47
    {
48 12
        return isset($this->options[$name]) ? $this->options[$name] : $default;
49
    }
50
51
    /**
52
     * Return all options.
53
     *
54
     * @return array
55
     */
56 8
    public function getAll() : array
57
    {
58 8
        return $this->options;
59
    }
60
}
61