Options   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 40
ccs 6
cts 6
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getAll() 0 3 1
A get() 0 3 1
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/captainhook-git/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, mixed>
28
     */
29
    private array $options;
30
31
    /**
32
     * Options constructor
33
     *
34
     * @param array<string, mixed> $options
35
     */
36 251
    public function __construct(array $options)
37
    {
38 251
        $this->options = $options;
39
    }
40
41
    /**
42
     * Return a option value
43
     *
44
     * @template ProvidedDefault
45
     * @param  string          $name
46
     * @param  ProvidedDefault $default
47
     * @return ProvidedDefault|mixed
48
     */
49 125
    public function get(string $name, $default = null)
50
    {
51 125
        return $this->options[$name] ?? $default;
52
    }
53
54
    /**
55
     * Return all options
56
     *
57
     * @return array<string, mixed>
58
     */
59 36
    public function getAll(): array
60
    {
61 36
        return $this->options;
62
    }
63
}
64