| Total Complexity | 6 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | final class OptionMap |
||
| 15 | { |
||
| 16 | /** @var array */ |
||
| 17 | private $options = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param string $name |
||
| 21 | * @return bool |
||
| 22 | */ |
||
| 23 | public function has(string $name): bool |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param string $name |
||
| 30 | * @return mixed |
||
| 31 | */ |
||
| 32 | public function get(string $name) |
||
| 33 | { |
||
| 34 | if (!$this->has($name)) { |
||
| 35 | throw new OptionException("Undefined option `{$name}`"); |
||
| 36 | } |
||
| 37 | |||
| 38 | return $this->options[$name]; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param string $name |
||
| 43 | * @param mixed $value |
||
| 44 | * @return OptionMap |
||
| 45 | */ |
||
| 46 | public function set(string $name, $value): self |
||
| 47 | { |
||
| 48 | $this->options[$name] = $value; |
||
| 49 | |||
| 50 | return $this; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param string $name |
||
| 55 | * @return OptionMap |
||
| 56 | */ |
||
| 57 | public function remove(string $name): self |
||
| 58 | { |
||
| 59 | unset($this->options[$name]); |
||
| 60 | |||
| 61 | return $this; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return \Traversable |
||
| 66 | */ |
||
| 67 | public function getIterator() |
||
| 70 | } |
||
| 71 | } |