GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Options::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BFW;
4
5
use \Exception;
6
7
/**
8
 * Class to manage Options
9
 */
10
class Options
11
{
12
    /**
13
     * @const ERR_KEY_NOT_EXIST Exception code if a key not exist.
14
     */
15
    const ERR_KEY_NOT_EXIST = 1106001;
16
    
17
    /**
18
     * @var array $option option's list
19
     */
20
    protected $options = [];
21
22
    /**
23
     * Constructor
24
     * Merge default option with passed values
25
     * 
26
     * @param array $defaultOptions Default options
27
     * @param array $options Options from applications/users
28
     */
29
    public function __construct(array $defaultOptions, array $options)
30
    {
31
        $this->options = array_merge($defaultOptions, $options);
32
    }
33
    
34
    /**
35
     * Getter accessor to options property
36
     * 
37
     * @return array
38
     */
39
    public function getOptions(): array
40
    {
41
        return $this->options;
42
    }
43
44
    /**
45
     * Get the value for an option
46
     * 
47
     * @param string $optionKey The option key
48
     * 
49
     * @return mixed
50
     * 
51
     * @throws \Exception If the key not exists
52
     */
53
    public function getValue(string $optionKey)
54
    {
55
        if (!isset($this->options[$optionKey])) {
56
            throw new Exception(
57
                'Option key '.$optionKey.' not exist.',
58
                $this::ERR_KEY_NOT_EXIST
59
            );
60
        }
61
62
        return $this->options[$optionKey];
63
    }
64
}
65