1 | <?php |
||
34 | class AppConfig { |
||
35 | private $appName = 'files_antivirus'; |
||
36 | |||
37 | /** @var IConfig */ |
||
38 | private $config; |
||
39 | |||
40 | private $defaults = [ |
||
41 | 'av_mode' => 'executable', |
||
42 | 'av_socket' => '/var/run/clamav/clamd.ctl', |
||
43 | 'av_host' => '', |
||
44 | 'av_port' => '', |
||
45 | 'av_cmd_options' => '', |
||
46 | 'av_path' => '/usr/bin/clamscan', |
||
47 | 'av_max_file_size' => -1, |
||
48 | 'av_stream_max_length' => '26214400', |
||
49 | 'av_infected_action' => 'only_log', |
||
50 | 'av_background_scan' => 'on', |
||
51 | ]; |
||
52 | |||
53 | /** |
||
54 | * AppConfig constructor. |
||
55 | * |
||
56 | * @param IConfig $config |
||
57 | 1 | */ |
|
58 | 1 | public function __construct(IConfig $config) { |
|
61 | |||
62 | public function getAvChunkSize() { |
||
67 | |||
68 | /** |
||
69 | * Get full commandline |
||
70 | * @return string |
||
71 | */ |
||
72 | public function getCmdline() { |
||
91 | |||
92 | /** |
||
93 | * Get all setting values as an array |
||
94 | * @return array |
||
95 | */ |
||
96 | public function getAllValues() { |
||
102 | |||
103 | /** |
||
104 | * Get a value by key |
||
105 | * @param string $key |
||
106 | * @return string |
||
107 | 1 | */ |
|
108 | 1 | public function getAppValue($key) { |
|
115 | |||
116 | /** |
||
117 | * Set a value by key |
||
118 | * @param string $key |
||
119 | * @param string $value |
||
120 | */ |
||
121 | public function setAppValue($key, $value) { |
||
124 | |||
125 | /** |
||
126 | * Set a value with magic __call invocation |
||
127 | * @param string $key |
||
128 | * @param array $args |
||
129 | * @throws \BadFunctionCallException |
||
130 | */ |
||
131 | protected function setter($key, $args) { |
||
138 | |||
139 | /** |
||
140 | * Get a value with magic __call invocation |
||
141 | * @param string $key |
||
142 | * @return string |
||
143 | * @throws \BadFunctionCallException |
||
144 | 1 | */ |
|
145 | 1 | protected function getter($key) { |
|
152 | |||
153 | /** |
||
154 | * Translates property_name into propertyName |
||
155 | * @param string $property |
||
156 | * @return string |
||
157 | */ |
||
158 | protected function camelCase($property) { |
||
163 | |||
164 | /** |
||
165 | * Does all the someConfig to some_config magic |
||
166 | * @param string $property |
||
167 | * @return string |
||
168 | 1 | */ |
|
169 | 1 | protected function propertyToKey($property) { |
|
183 | |||
184 | /** |
||
185 | * Get/set an option value by calling getSomeOption method |
||
186 | * @param string $methodName |
||
187 | * @param array $args |
||
188 | * @return string|null |
||
189 | * @throws \BadFunctionCallException |
||
190 | 1 | */ |
|
191 | 1 | public function __call($methodName, $args) { |
|
203 | } |
||
204 |