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