1 | <?php |
||
31 | class AppConfig { |
||
32 | private $appName = 'files_antivirus'; |
||
33 | private $config; |
||
34 | |||
35 | private $defaults = array( |
||
36 | 'av_mode' => 'executable', |
||
37 | 'av_socket' => '/var/run/clamav/clamd.ctl', |
||
38 | 'av_host' => '', |
||
39 | 'av_port' => '', |
||
40 | 'av_cmd_options' => '', |
||
41 | 'av_chunk_size' => '1024', |
||
42 | 'av_path' => '/usr/bin/clamscan', |
||
43 | 'av_infected_action' => 'only_log', |
||
44 | ); |
||
45 | |||
46 | 4 | public function __construct(IConfig $config) { |
|
49 | |||
50 | /** |
||
51 | * Get full commandline |
||
52 | * @return string |
||
53 | */ |
||
54 | 2 | public function getCmdline(){ |
|
73 | |||
74 | /** |
||
75 | * Get all setting values as an array |
||
76 | * @return array |
||
77 | */ |
||
78 | public function getAllValues() { |
||
84 | |||
85 | /** |
||
86 | * Get a value by key |
||
87 | * @param string $key |
||
88 | * @return string |
||
89 | */ |
||
90 | 4 | public function getAppValue($key) { |
|
97 | |||
98 | /** |
||
99 | * Set a value by key |
||
100 | * @param string $key |
||
101 | * @param string $value |
||
102 | */ |
||
103 | public function setAppValue($key, $value) { |
||
106 | |||
107 | /** |
||
108 | * Set a value with magic __call invocation |
||
109 | * @param string $key |
||
110 | * @param array $args |
||
111 | * @throws \BadFunctionCallException |
||
112 | */ |
||
113 | protected function setter($key, $args) { |
||
120 | |||
121 | /** |
||
122 | * Get a value with magic __call invocation |
||
123 | * @param string $key |
||
124 | * @return string |
||
125 | * @throws \BadFunctionCallException |
||
126 | */ |
||
127 | 4 | protected function getter($key) { |
|
134 | |||
135 | /** |
||
136 | * Translates property_name into propertyName |
||
137 | * @param string $property |
||
138 | * @return string |
||
139 | */ |
||
140 | protected function camelCase($property){ |
||
146 | |||
147 | /** |
||
148 | * Does all the someConfig to some_config magic |
||
149 | * @param string $property |
||
150 | * @return string |
||
151 | */ |
||
152 | 4 | protected function propertyToKey($property){ |
|
166 | |||
167 | /** |
||
168 | * Get/set an option value by calling getSomeOption method |
||
169 | * @param string $methodName |
||
170 | * @param array $args |
||
171 | * @return string|null |
||
172 | * @throws \BadFunctionCallException |
||
173 | */ |
||
174 | 4 | public function __call($methodName, $args){ |
|
186 | } |
||
187 |