1 | <?php |
||
37 | class AppConfig { |
||
38 | private $appName = 'files_antivirus'; |
||
39 | |||
40 | /** @var IConfig */ |
||
41 | private $config; |
||
42 | |||
43 | private $defaults = [ |
||
44 | 'av_mode' => 'executable', |
||
45 | 'av_socket' => '/var/run/clamav/clamd.ctl', |
||
46 | 'av_host' => '', |
||
47 | 'av_port' => '', |
||
48 | 'av_cmd_options' => '', |
||
49 | 'av_path' => '/usr/bin/clamscan', |
||
50 | 'av_max_file_size' => -1, |
||
51 | 'av_stream_max_length' => '26214400', |
||
52 | 'av_infected_action' => 'only_log', |
||
53 | 'av_scan_background' => 'true', |
||
54 | ]; |
||
55 | |||
56 | /** |
||
57 | * AppConfig constructor. |
||
58 | * |
||
59 | * @param IConfig $config |
||
60 | */ |
||
61 | 12 | public function __construct(IConfig $config) { |
|
64 | |||
65 | 5 | public function getAvChunkSize(){ |
|
70 | |||
71 | /** |
||
72 | * Get full commandline |
||
73 | * @return string |
||
74 | */ |
||
75 | 1 | public function getCmdline(){ |
|
94 | |||
95 | /** |
||
96 | * Get all setting values as an array |
||
97 | * @return array |
||
98 | */ |
||
99 | 3 | public function getAllValues() { |
|
105 | |||
106 | /** |
||
107 | * Get a value by key |
||
108 | * @param string $key |
||
109 | * @return string |
||
110 | */ |
||
111 | 4 | public function getAppValue($key) { |
|
118 | |||
119 | /** |
||
120 | * Set a value by key |
||
121 | * @param string $key |
||
122 | * @param string $value |
||
123 | * @return string |
||
124 | */ |
||
125 | 1 | public function setAppValue($key, $value) { |
|
128 | |||
129 | /** |
||
130 | * Set a value with magic __call invocation |
||
131 | * @param string $key |
||
132 | * @param array $args |
||
133 | * @throws \BadFunctionCallException |
||
134 | */ |
||
135 | 1 | protected function setter($key, $args) { |
|
142 | |||
143 | /** |
||
144 | * Get a value with magic __call invocation |
||
145 | * @param string $key |
||
146 | * @return string |
||
147 | * @throws \BadFunctionCallException |
||
148 | */ |
||
149 | 8 | protected function getter($key) { |
|
156 | |||
157 | /** |
||
158 | * Translates property_name into propertyName |
||
159 | * @param string $property |
||
160 | * @return string |
||
161 | */ |
||
162 | 3 | protected function camelCase($property){ |
|
168 | |||
169 | /** |
||
170 | * Does all the someConfig to some_config magic |
||
171 | * @param string $property |
||
172 | * @return string |
||
173 | */ |
||
174 | 11 | protected function propertyToKey($property){ |
|
188 | |||
189 | /** |
||
190 | * Get/set an option value by calling getSomeOption method |
||
191 | * @param string $methodName |
||
192 | * @param array $args |
||
193 | * @return string|null |
||
194 | * @throws \BadFunctionCallException |
||
195 | */ |
||
196 | 11 | public function __call($methodName, $args){ |
|
208 | } |
||
209 |