Passed
Push — master ( 69774c...de7969 )
by Sebastian
02:46
created

Options   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 5
c 0
b 0
f 0
dl 0
loc 39
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAll() 0 3 1
A __construct() 0 3 1
A get() 0 3 2
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Config;
13
14
/**
15
 * Class Options
16
 *
17
 * @package CaptainHook
18
 * @author  Sebastian Feldmann <[email protected]>
19
 * @link    https://github.com/captainhookphp/captainhook
20
 * @since   Class available since Release 1.0.0
21
 */
22
class Options
23
{
24
    /**
25
     * Map of options
26
     *
27
     * @var array<string, string>
28
     */
29
    private $options;
30
31
    /**
32
     * Options constructor
33
     *
34
     * @param array<string, string> $options
35 68
     */
36
    public function __construct(array $options)
37 68
    {
38 68
        $this->options = $options;
39
    }
40
41
    /**
42
     * Return a option value
43
     *
44
     * @param  string $name
45
     * @param  mixed  $default
46
     * @return mixed
47 18
     */
48
    public function get(string $name, $default = null)
49 18
    {
50
        return isset($this->options[$name]) ? $this->options[$name] : $default;
51
    }
52
53
    /**
54
     * Return all options
55
     *
56
     * @return array
57 14
     */
58
    public function getAll(): array
59 14
    {
60
        return $this->options;
61
    }
62
}
63