1 | <?php |
||
37 | class AppConfig { |
||
38 | private $appName = 'files_antivirus'; |
||
39 | |||
40 | /** |
||
41 | * @var IConfig |
||
42 | */ |
||
43 | private $config; |
||
44 | |||
45 | private $defaults = [ |
||
46 | 'av_mode' => 'executable', |
||
47 | 'av_socket' => '/var/run/clamav/clamd.ctl', |
||
48 | 'av_host' => '', |
||
49 | 'av_port' => '', |
||
50 | 'av_cmd_options' => '', |
||
51 | 'av_path' => '/usr/bin/clamscan', |
||
52 | 'av_max_file_size' => -1, |
||
53 | 'av_stream_max_length' => '26214400', |
||
54 | 'av_infected_action' => 'only_log', |
||
55 | 'av_scan_background' => 'true', |
||
56 | ]; |
||
57 | |||
58 | /** |
||
59 | * AppConfig constructor. |
||
60 | * |
||
61 | * @param IConfig $config |
||
62 | */ |
||
63 | 12 | public function __construct(IConfig $config) { |
|
66 | |||
67 | 5 | public function getAvChunkSize() { |
|
72 | |||
73 | /** |
||
74 | * Get full commandline |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | 1 | public function getCmdline() { |
|
98 | |||
99 | /** |
||
100 | * Get all setting values as an array |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | 3 | public function getAllValues() { |
|
110 | |||
111 | /** |
||
112 | * Get a value by key |
||
113 | * |
||
114 | * @param string $key |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | 4 | public function getAppValue($key) { |
|
125 | |||
126 | /** |
||
127 | * Set a value by key |
||
128 | * |
||
129 | * @param string $key |
||
130 | * @param string $value |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | 1 | public function setAppValue($key, $value) { |
|
137 | |||
138 | /** |
||
139 | * Set a value with magic __call invocation |
||
140 | * |
||
141 | * @param string $key |
||
142 | * @param array $args |
||
143 | * |
||
144 | * @throws \BadFunctionCallException |
||
145 | */ |
||
146 | 1 | protected function setter($key, $args) { |
|
153 | |||
154 | /** |
||
155 | * Get a value with magic __call invocation |
||
156 | * |
||
157 | * @param string $key |
||
158 | * |
||
159 | * @return string |
||
160 | * |
||
161 | * @throws \BadFunctionCallException |
||
162 | */ |
||
163 | 8 | protected function getter($key) { |
|
170 | |||
171 | /** |
||
172 | * Translates property_name into propertyName |
||
173 | * |
||
174 | * @param string $property |
||
175 | * |
||
176 | * @return string |
||
177 | */ |
||
178 | 3 | protected function camelCase($property) { |
|
184 | |||
185 | /** |
||
186 | * Does all the someConfig to some_config magic |
||
187 | * |
||
188 | * @param string $property |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | 11 | protected function propertyToKey($property) { |
|
206 | |||
207 | /** |
||
208 | * Get/set an option value by calling getSomeOption method |
||
209 | * |
||
210 | * @param string $methodName |
||
211 | * @param array $args |
||
212 | * |
||
213 | * @return string|null |
||
214 | * |
||
215 | * @throws \BadFunctionCallException |
||
216 | */ |
||
217 | 11 | public function __call($methodName, $args) { |
|
230 | } |
||
231 |