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_chunk_size' => '1024', |
||
48 | 'av_path' => '/usr/bin/clamscan', |
||
49 | 'av_max_file_size' => -1, |
||
50 | '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 | /** |
||
63 | * Get full commandline |
||
64 | * @return string |
||
65 | */ |
||
66 | public function getCmdline(){ |
||
85 | |||
86 | /** |
||
87 | * Get all setting values as an array |
||
88 | * @return array |
||
89 | */ |
||
90 | public function getAllValues() { |
||
96 | |||
97 | /** |
||
98 | * Get a value by key |
||
99 | * @param string $key |
||
100 | * @return string |
||
101 | */ |
||
102 | public function getAppValue($key) { |
||
109 | |||
110 | /** |
||
111 | * Set a value by key |
||
112 | * @param string $key |
||
113 | * @param string $value |
||
114 | * @return string |
||
115 | */ |
||
116 | public function setAppValue($key, $value) { |
||
119 | |||
120 | /** |
||
121 | * Set a value with magic __call invocation |
||
122 | * @param string $key |
||
123 | * @param array $args |
||
124 | * @throws \BadFunctionCallException |
||
125 | */ |
||
126 | protected function setter($key, $args) { |
||
133 | |||
134 | /** |
||
135 | * Get a value with magic __call invocation |
||
136 | * @param string $key |
||
137 | * @return string |
||
138 | * @throws \BadFunctionCallException |
||
139 | */ |
||
140 | protected function getter($key) { |
||
147 | |||
148 | /** |
||
149 | * Translates property_name into propertyName |
||
150 | * @param string $property |
||
151 | * @return string |
||
152 | */ |
||
153 | protected function camelCase($property){ |
||
159 | |||
160 | /** |
||
161 | * Does all the someConfig to some_config magic |
||
162 | * @param string $property |
||
163 | * @return string |
||
164 | */ |
||
165 | protected function propertyToKey($property){ |
||
179 | |||
180 | /** |
||
181 | * Get/set an option value by calling getSomeOption method |
||
182 | * @param string $methodName |
||
183 | * @param array $args |
||
184 | * @return string|null |
||
185 | * @throws \BadFunctionCallException |
||
186 | */ |
||
187 | public function __call($methodName, $args){ |
||
199 | } |
||
200 |