| Total Complexity | 13 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Coverage | 60% |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class Service implements Interfaces\IService |
||
| 7 | { |
||
| 8 | protected $parametersList = array(); |
||
| 9 | protected $parametersValues = array(); |
||
| 10 | |||
| 11 | 7 | public function __construct() |
|
| 12 | { |
||
| 13 | // Service constructor |
||
| 14 | 7 | } |
|
| 15 | |||
| 16 | 5 | public function __get($variable) |
|
| 17 | { |
||
| 18 | 5 | if (in_array($variable, $this->parametersList)) { |
|
| 19 | 4 | if (isset($this->parametersValues[$variable])) { |
|
| 20 | 4 | return $this->parametersValues[$variable]; |
|
| 21 | } else { |
||
| 22 | return null; |
||
| 23 | } |
||
| 24 | } else { |
||
| 25 | 1 | throw new InvalidArgumentException("Unknown configuration property " . get_called_class() . '->' .$variable); |
|
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | 5 | public function __set($variable, $value) |
|
| 30 | { |
||
| 31 | 5 | if (in_array($variable, $this->parametersList)) { |
|
| 32 | 4 | $this->parametersValues[$variable] = $value; |
|
| 33 | |||
| 34 | 4 | return $this; |
|
| 35 | } else { |
||
| 36 | 1 | throw new InvalidArgumentException("Unknown configuration property " . get_called_class() . '->' . $variable); |
|
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | public function configure($parameters = array()) |
||
| 51 | } |
||
| 52 | |||
| 53 | 1 | public function getParameter($parameter) |
|
| 54 | { |
||
| 55 | 1 | if (in_array($parameter, $this->parametersList)) { |
|
| 56 | 1 | return isset($this->parametersValues[$parameter]) ? $this->parametersValues[$parameter] : null; |
|
| 57 | } else { |
||
| 58 | throw new InvalidArgumentException("Unknown configuration property : " . get_called_class() . "->" . $parameter); |
||
| 59 | } |
||
| 60 | } |
||
| 61 | |||
| 62 | protected function init() |
||
| 64 | } |
||
| 65 | } |
||
| 66 |