| Total Complexity | 10 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class Service implements Interfaces\IService |
||
| 10 | { |
||
| 11 | protected $parametersList = []; |
||
| 12 | protected $parametersValues = []; |
||
| 13 | |||
| 14 | 73 | public function __construct() |
|
| 15 | { |
||
| 16 | // Service constructor |
||
| 17 | 73 | } |
|
| 18 | |||
| 19 | 56 | public function __get($variable) |
|
| 20 | { |
||
| 21 | 56 | if (in_array($variable, $this->parametersList)) { |
|
| 22 | 55 | if (isset($this->parametersValues[$variable])) { |
|
| 23 | 55 | return $this->parametersValues[$variable]; |
|
| 24 | } |
||
| 25 | |||
| 26 | 5 | return null; |
|
| 27 | } |
||
| 28 | |||
| 29 | 1 | throw new InvalidArgumentException( |
|
| 30 | "Unknown configuration property " . |
||
| 31 | 1 | get_called_class() . |
|
| 32 | 1 | '->' . |
|
| 33 | 1 | $variable |
|
| 34 | ); |
||
| 35 | } |
||
| 36 | |||
| 37 | 60 | public function __set($variable, $value) |
|
| 38 | { |
||
| 39 | 60 | if (in_array($variable, $this->parametersList)) { |
|
| 40 | 59 | $this->parametersValues[$variable] = $value; |
|
| 41 | |||
| 42 | 59 | return $this; |
|
| 43 | } |
||
| 44 | |||
| 45 | 2 | throw new InvalidArgumentException( |
|
| 46 | "Unknown configuration property " . |
||
| 47 | 2 | get_called_class() . |
|
| 48 | 2 | '->' . |
|
| 49 | 2 | $variable |
|
| 50 | ); |
||
| 51 | } |
||
| 52 | |||
| 53 | 37 | public function configure($parameters = []) |
|
| 60 | 37 | } |
|
| 61 | |||
| 62 | 11 | public function getParameter($parameter) |
|
| 63 | { |
||
| 64 | 11 | return $this->$parameter; |
|
| 65 | } |
||
| 66 | |||
| 67 | 37 | protected function init() |
|
| 69 | 37 | } |
|
| 70 | } |
||
| 71 |