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