| Total Complexity | 8 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | final class ConfigurationAdapter |
||
| 11 | { |
||
| 12 | private $config; |
||
| 13 | /** @var ParameterBag */ |
||
| 14 | private $options; |
||
| 15 | |||
| 16 | public function __construct(AbstractConfiguration $config) |
||
| 17 | { |
||
| 18 | $this->config = $config; |
||
| 19 | } |
||
| 20 | |||
| 21 | public function __toString() : string |
||
| 22 | { |
||
| 23 | return Str::formatAsTable($this->getOptions()->all()); |
||
| 24 | } |
||
| 25 | |||
| 26 | public function get(string $optionName) |
||
| 27 | { |
||
| 28 | if (!$this->getOptions()->has($optionName)) { |
||
| 29 | throw new \InvalidArgumentException(sprintf('The "%s" option is not defined.', $optionName)); |
||
| 30 | } |
||
| 31 | |||
| 32 | return $this->getOptions()->get($optionName); |
||
| 33 | } |
||
| 34 | |||
| 35 | private function getOptions() : ParameterBag |
||
| 57 | } |
||
| 58 | } |
||
| 59 |