| Total Complexity | 4 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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) |
||
| 63 | } |
||
| 64 | } |
||
| 65 |