1 | <?php |
||
13 | class Config implements ConfigInterface |
||
14 | { |
||
15 | /** |
||
16 | * Array of parameters (with some default values) |
||
17 | * @var array |
||
18 | */ |
||
19 | private $_parameters = [ |
||
20 | 'legacy' => Client::LEGACY, |
||
21 | 'ssl' => Client::SSL, |
||
22 | 'timeout' => Client::TIMEOUT, |
||
23 | 'attempts' => Client::ATTEMPTS, |
||
24 | 'delay' => Client::ATTEMPTS_DELAY |
||
25 | ]; |
||
26 | |||
27 | /** |
||
28 | * Check if key in list of allowed parameters |
||
29 | * |
||
30 | * @param string $key |
||
31 | * @param array $array |
||
32 | * @throws ConfigException |
||
33 | */ |
||
34 | 7 | private function keyAllowed(string $key, array $array) |
|
41 | |||
42 | /** |
||
43 | * Compare data types of some value |
||
44 | * |
||
45 | * @param string $name Name of value |
||
46 | * @param mixed $whatType What type has value |
||
47 | * @param mixed $isType What type should be |
||
48 | * @throws ConfigException |
||
49 | */ |
||
50 | 3 | private function keyType(string $name, $whatType, $isType) |
|
56 | |||
57 | /** |
||
58 | * Set parameter into array |
||
59 | * |
||
60 | * @param string $name |
||
61 | * @param mixed $value |
||
62 | * @return ConfigInterface |
||
63 | * @throws ConfigException |
||
64 | */ |
||
65 | 4 | public function set(string $name, $value): ConfigInterface |
|
78 | |||
79 | /** |
||
80 | * Return port number (get from defaults if port is not set by user) |
||
81 | * |
||
82 | * @param string $parameter |
||
83 | * @return bool|int |
||
84 | */ |
||
85 | 1 | private function getPort(string $parameter) |
|
96 | |||
97 | /** |
||
98 | * Remove parameter from array by name |
||
99 | * |
||
100 | * @param string $parameter |
||
101 | * @return ConfigInterface |
||
102 | * @throws ConfigException |
||
103 | */ |
||
104 | 3 | public function delete(string $parameter): ConfigInterface |
|
114 | |||
115 | /** |
||
116 | * Return parameter of current config by name |
||
117 | * |
||
118 | * @param string $parameter |
||
119 | * @return mixed |
||
120 | * @throws ConfigException |
||
121 | */ |
||
122 | 2 | public function get(string $parameter) |
|
129 | |||
130 | /** |
||
131 | * Return array with all parameters of configuration |
||
132 | * |
||
133 | * @return array |
||
134 | */ |
||
135 | 3 | public function getParameters(): array |
|
139 | } |
||
140 |