| Total Complexity | 9 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | class Config implements \ArrayAccess |
||
| 22 | { |
||
| 23 | private $configs = array(); |
||
| 24 | |||
| 25 | public function all() |
||
| 26 | { |
||
| 27 | return $this->configs; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function get($name) |
||
| 31 | { |
||
| 32 | if (!array_key_exists($name, $this->configs)) { |
||
| 33 | throw new InvalidArgumentException('Config key "'.$name.'" not exists.'); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $this->configs[$name]; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * {@inheritdoc} |
||
| 41 | */ |
||
| 42 | public function offsetExists($offset) |
||
| 43 | { |
||
| 44 | return isset($this->configs[$offset]); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * {@inheritdoc} |
||
| 49 | */ |
||
| 50 | public function offsetGet($offset) |
||
| 51 | { |
||
| 52 | return $this->configs[$offset]; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * {@inheritdoc} |
||
| 57 | */ |
||
| 58 | public function offsetSet($offset, $value): void |
||
| 59 | { |
||
| 60 | $this->configs[$offset] = $value; |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * {@inheritdoc} |
||
| 65 | */ |
||
| 66 | public function offsetUnset($offset): void |
||
| 67 | { |
||
| 68 | unset($this->configs[$offset]); |
||
| 69 | } |
||
| 70 | |||
| 71 | public function set($name, $value): self |
||
| 72 | { |
||
| 73 | $this->configs[$name] = $value; |
||
| 74 | |||
| 75 | return $this; |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @param array $configs |
||
| 80 | */ |
||
| 81 | public function setConfigs(array $configs): void |
||
| 84 | } |
||
| 85 | } |
||
| 86 |