@@ -103,8 +103,9 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getOption($key, $name) |
105 | 105 | { |
106 | - if (!array_key_exists($key, $this->options)) |
|
107 | - throw new \LogicException("The option '$key' does not exists"); |
|
106 | + if (!array_key_exists($key, $this->options)) { |
|
107 | + throw new \LogicException("The option '$key' does not exists"); |
|
108 | + } |
|
108 | 109 | |
109 | 110 | return array_key_exists($name, $this->options[$key]) ? $this->options[$key][$name] : null; |
110 | 111 | } |
@@ -158,8 +159,9 @@ discard block |
||
158 | 159 | |
159 | 160 | foreach ($attribs as $key => $attributes) |
160 | 161 | { |
161 | - if (!array_key_exists($key, $attribs)) |
|
162 | - throw new \LogicException("The field '$key' does not exists!"); |
|
162 | + if (!array_key_exists($key, $attribs)) { |
|
163 | + throw new \LogicException("The field '$key' does not exists!"); |
|
164 | + } |
|
163 | 165 | |
164 | 166 | $label = (array_key_exists('label', array_keys($this->options))) ? $attributes["label"] : $key; |
165 | 167 | |
@@ -225,19 +227,21 @@ discard block |
||
225 | 227 | |
226 | 228 | case 'min': |
227 | 229 | |
228 | - if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) |
|
229 | - $validator = new GreaterThan(['min' => $value, 'inclusive' => true]); |
|
230 | - else |
|
231 | - throw new \LogicException("The input type must be 'range' or 'number'"); |
|
230 | + if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) { |
|
231 | + $validator = new GreaterThan(['min' => $value, 'inclusive' => true]); |
|
232 | + } else { |
|
233 | + throw new \LogicException("The input type must be 'range' or 'number'"); |
|
234 | + } |
|
232 | 235 | |
233 | 236 | break; |
234 | 237 | |
235 | 238 | case 'max': |
236 | 239 | |
237 | - if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) |
|
238 | - $validator = new LessThan(['max' => $value, 'inclusive' => true]); |
|
239 | - else |
|
240 | - throw new \LogicException("The input type must be 'range' or 'number'"); |
|
240 | + if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) { |
|
241 | + $validator = new LessThan(['max' => $value, 'inclusive' => true]); |
|
242 | + } else { |
|
243 | + throw new \LogicException("The input type must be 'range' or 'number'"); |
|
244 | + } |
|
241 | 245 | |
242 | 246 | break; |
243 | 247 | |
@@ -245,10 +249,11 @@ discard block |
||
245 | 249 | |
246 | 250 | $baseValue = (array_key_exists('min', $all_attribs)) ? $all_attribs['min'] : 0; |
247 | 251 | |
248 | - if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['range'])) |
|
249 | - $validator = new Step(['baseValue' => $baseValue, 'step' => $value]); |
|
250 | - else |
|
251 | - throw new \LogicException("The input type must be 'range'"); |
|
252 | + if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['range'])) { |
|
253 | + $validator = new Step(['baseValue' => $baseValue, 'step' => $value]); |
|
254 | + } else { |
|
255 | + throw new \LogicException("The input type must be 'range'"); |
|
256 | + } |
|
252 | 257 | |
253 | 258 | break; |
254 | 259 | } |
@@ -272,8 +277,9 @@ discard block |
||
272 | 277 | $validator = new NotEmpty(); |
273 | 278 | $attribute = $this->formHandler->getAttribute($key, "value"); |
274 | 279 | |
275 | - if (is_null($attribute)) |
|
276 | - throw new \LogicException("Missing attribute 'value' in '" . $key . "'."); |
|
280 | + if (is_null($attribute)) { |
|
281 | + throw new \LogicException("Missing attribute 'value' in '" . $key . "'."); |
|
282 | + } |
|
277 | 283 | |
278 | 284 | $value = $attribute->getValue(); |
279 | 285 | |
@@ -287,8 +293,9 @@ discard block |
||
287 | 293 | { |
288 | 294 | $className = "\Zend\I18n\Validator\\" . $class; |
289 | 295 | |
290 | - if (!class_exists($className)) |
|
291 | - throw new \RuntimeException("The class '$userInputClass' or '$className' does not exists"); |
|
296 | + if (!class_exists($className)) { |
|
297 | + throw new \RuntimeException("The class '$userInputClass' or '$className' does not exists"); |
|
298 | + } |
|
292 | 299 | } |
293 | 300 | |
294 | 301 | $validator = new $className($params); |
@@ -326,21 +333,22 @@ discard block |
||
326 | 333 | $v->setTranslator($this->translator); |
327 | 334 | $notEmpty = $v->isValid($val); |
328 | 335 | |
329 | - if (!$required && !$notEmpty) |
|
330 | - return null; |
|
336 | + if (!$required && !$notEmpty) { |
|
337 | + return null; |
|
338 | + } |
|
331 | 339 | |
332 | 340 | $valid = $validator->isValid($val); |
333 | 341 | $this->setValid($valid); |
334 | 342 | |
335 | 343 | if (!$valid) |
336 | 344 | { |
337 | - if (!in_array($key, array_keys($this->messages))) |
|
338 | - $this->messages[$key] = array(); |
|
345 | + if (!in_array($key, array_keys($this->messages))) { |
|
346 | + $this->messages[$key] = array(); |
|
347 | + } |
|
339 | 348 | |
340 | 349 | $this->messages[$key] = array_merge($this->messages[$key], $validator->getMessages()); |
341 | 350 | } |
342 | - } |
|
343 | - else { |
|
351 | + } else { |
|
344 | 352 | foreach ($form_value as $val) |
345 | 353 | { |
346 | 354 | $this->_validate($validator, $val, $key, $required); |
@@ -93,24 +93,24 @@ discard block |
||
93 | 93 | { |
94 | 94 | foreach ($contents as $i) |
95 | 95 | { |
96 | - if (is_file($handler.'/'.$i)) |
|
96 | + if (is_file($handler . '/' . $i)) |
|
97 | 97 | { |
98 | - $allContents[] = $handler.'/'.$i; |
|
98 | + $allContents[] = $handler . '/' . $i; |
|
99 | 99 | |
100 | - $this->buffer = $handler.'/'.$i; |
|
100 | + $this->buffer = $handler . '/' . $i; |
|
101 | 101 | call_user_func($fileCallback, $this); |
102 | 102 | } |
103 | - elseif (is_dir($handler.'/'.$i)) |
|
103 | + elseif (is_dir($handler . '/' . $i)) |
|
104 | 104 | { |
105 | - $allContents[] = $handler.'/'.$i; |
|
105 | + $allContents[] = $handler . '/' . $i; |
|
106 | 106 | |
107 | - $this->buffer = $handler.'/'.$i; |
|
108 | - $this->getContents($handler.'/'.$i, $fileCallback, $dirCallback); |
|
107 | + $this->buffer = $handler . '/' . $i; |
|
108 | + $this->getContents($handler . '/' . $i, $fileCallback, $dirCallback); |
|
109 | 109 | |
110 | 110 | $directory = scandir($handler); |
111 | 111 | |
112 | 112 | if (!count($directory) < 3) |
113 | - $this->buffer = $handler.'/'.$i; |
|
113 | + $this->buffer = $handler . '/' . $i; |
|
114 | 114 | |
115 | 115 | call_user_func($dirCallback, $this); |
116 | 116 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | if (!empty($path)) |
198 | 198 | if (!strlen(stristr($item, $path)) > 0) |
199 | 199 | continue; |
200 | - if (strstr($item,'~') === false && $item != '.' && $item != '..') |
|
200 | + if (strstr($item, '~') === false && $item != '.' && $item != '..') |
|
201 | 201 | $filesToReturn[] = $item; |
202 | 202 | } |
203 | 203 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | if (is_dir($dest)) |
301 | 301 | { |
302 | 302 | if (!$recursive) |
303 | - copy($file, $dest.'/'.$file); |
|
303 | + copy($file, $dest . '/' . $file); |
|
304 | 304 | else { |
305 | 305 | |
306 | 306 | $files = array(); |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | |
320 | 320 | foreach ($files[1] as $item) |
321 | 321 | { |
322 | - if (!file_exists($dest.'/'.$item)) |
|
322 | + if (!file_exists($dest . '/' . $item)) |
|
323 | 323 | mkdir("$dest/$item", 0777, true); |
324 | 324 | } |
325 | 325 | |
326 | 326 | foreach ($files[0] as $item) |
327 | 327 | { |
328 | 328 | if (!file_exists("$dest/$files")) |
329 | - copy($item, $dest.'/'.$item); |
|
329 | + copy($item, $dest . '/' . $item); |
|
330 | 330 | } |
331 | 331 | }); |
332 | 332 | } |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | throw new Exception("Missing parameter for mv!"); |
352 | 352 | |
353 | 353 | if (is_dir($newfile)) |
354 | - $newfile .= '/'.basename($oldfile); |
|
354 | + $newfile .= '/' . basename($oldfile); |
|
355 | 355 | |
356 | 356 | if ($oldfile == $newfile) |
357 | 357 | return $this; |
358 | 358 | |
359 | - if(!rename($oldfile, $newfile)) |
|
359 | + if (!rename($oldfile, $newfile)) |
|
360 | 360 | return false; |
361 | 361 | |
362 | 362 | return true; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | else { |
387 | 387 | if (!is_dir($dir)) |
388 | 388 | { |
389 | - if(!mkdir("$dir", 0777)) |
|
389 | + if (!mkdir("$dir", 0777)) |
|
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | } |
@@ -83,8 +83,9 @@ discard block |
||
83 | 83 | |
84 | 84 | foreach ($filesForHandler as $item) |
85 | 85 | { |
86 | - if ($item != '.' && $item != '..') |
|
87 | - $contents[] = $item; |
|
86 | + if ($item != '.' && $item != '..') { |
|
87 | + $contents[] = $item; |
|
88 | + } |
|
88 | 89 | } |
89 | 90 | |
90 | 91 | $allContents = $contents; |
@@ -99,8 +100,7 @@ discard block |
||
99 | 100 | |
100 | 101 | $this->buffer = $handler.'/'.$i; |
101 | 102 | call_user_func($fileCallback, $this); |
102 | - } |
|
103 | - elseif (is_dir($handler.'/'.$i)) |
|
103 | + } elseif (is_dir($handler.'/'.$i)) |
|
104 | 104 | { |
105 | 105 | $allContents[] = $handler.'/'.$i; |
106 | 106 | |
@@ -109,19 +109,21 @@ discard block |
||
109 | 109 | |
110 | 110 | $directory = scandir($handler); |
111 | 111 | |
112 | - if (!count($directory) < 3) |
|
113 | - $this->buffer = $handler.'/'.$i; |
|
112 | + if (!count($directory) < 3) { |
|
113 | + $this->buffer = $handler.'/'.$i; |
|
114 | + } |
|
114 | 115 | |
115 | 116 | call_user_func($dirCallback, $this); |
116 | 117 | } |
117 | 118 | } |
118 | 119 | } |
120 | + } else { |
|
121 | + throw new Exception("The directory '$handler' does not exists"); |
|
119 | 122 | } |
120 | - else |
|
121 | - throw new Exception("The directory '$handler' does not exists"); |
|
122 | 123 | |
123 | - if (!is_null($callback)) |
|
124 | - call_user_func($callback, $this); |
|
124 | + if (!is_null($callback)) { |
|
125 | + call_user_func($callback, $this); |
|
126 | + } |
|
125 | 127 | |
126 | 128 | return $allContents; |
127 | 129 | } |
@@ -133,10 +135,11 @@ discard block |
||
133 | 135 | */ |
134 | 136 | public function pwd() |
135 | 137 | { |
136 | - if (getcwd()) |
|
137 | - $this->buffer = getcwd(); |
|
138 | - else |
|
139 | - return false; |
|
138 | + if (getcwd()) { |
|
139 | + $this->buffer = getcwd(); |
|
140 | + } else { |
|
141 | + return false; |
|
142 | + } |
|
140 | 143 | |
141 | 144 | return $this->buffer; |
142 | 145 | } |
@@ -155,9 +158,9 @@ discard block |
||
155 | 158 | |
156 | 159 | $path = (is_null($path) || empty($path)) ? '.' : $path; |
157 | 160 | |
158 | - if (is_file($path)) |
|
159 | - $filesToReturn = array($path); |
|
160 | - elseif (is_dir($path)) |
|
161 | + if (is_file($path)) { |
|
162 | + $filesToReturn = array($path); |
|
163 | + } elseif (is_dir($path)) |
|
161 | 164 | { |
162 | 165 | $pathIns = dir($path); |
163 | 166 | |
@@ -179,26 +182,26 @@ discard block |
||
179 | 182 | foreach ($files as $item) { |
180 | 183 | $filesToReturn[] = $item; |
181 | 184 | } |
182 | - } |
|
183 | - else { |
|
185 | + } else { |
|
184 | 186 | while (false !== ($item = $pathIns->read())) { |
185 | 187 | $filesToReturn[] = $item; |
186 | 188 | } |
187 | 189 | $pathIns->close(); |
188 | 190 | } |
189 | - } |
|
190 | - else { |
|
191 | + } else { |
|
191 | 192 | |
192 | 193 | $pathIns = dir('.'); |
193 | 194 | $contents = $this->ls(); |
194 | 195 | |
195 | 196 | foreach ($contents as $item) |
196 | 197 | { |
197 | - if (!empty($path)) |
|
198 | - if (!strlen(stristr($item, $path)) > 0) |
|
198 | + if (!empty($path)) { |
|
199 | + if (!strlen(stristr($item, $path)) > 0) |
|
199 | 200 | continue; |
200 | - if (strstr($item,'~') === false && $item != '.' && $item != '..') |
|
201 | - $filesToReturn[] = $item; |
|
201 | + } |
|
202 | + if (strstr($item,'~') === false && $item != '.' && $item != '..') { |
|
203 | + $filesToReturn[] = $item; |
|
204 | + } |
|
202 | 205 | } |
203 | 206 | } |
204 | 207 | |
@@ -218,8 +221,9 @@ discard block |
||
218 | 221 | |
219 | 222 | if (is_dir($path)) |
220 | 223 | { |
221 | - if (chdir($moveTo)) |
|
222 | - return true; |
|
224 | + if (chdir($moveTo)) { |
|
225 | + return true; |
|
226 | + } |
|
223 | 227 | } |
224 | 228 | |
225 | 229 | return false; |
@@ -236,11 +240,13 @@ discard block |
||
236 | 240 | { |
237 | 241 | if (file_exists($file)) |
238 | 242 | { |
239 | - if (!$openFile = fopen($file, 'w+')) |
|
240 | - return false; |
|
243 | + if (!$openFile = fopen($file, 'w+')) { |
|
244 | + return false; |
|
245 | + } |
|
241 | 246 | |
242 | - if (fwrite($openFile, "")) |
|
243 | - return true; |
|
247 | + if (fwrite($openFile, "")) { |
|
248 | + return true; |
|
249 | + } |
|
244 | 250 | |
245 | 251 | fclose($openFile); |
246 | 252 | } |
@@ -260,12 +266,13 @@ discard block |
||
260 | 266 | { |
261 | 267 | $recursive = is_null($recursive) ? false : $recursive; |
262 | 268 | |
263 | - if (is_null($file)) |
|
264 | - throw new Exception("Missing parameter for rm!"); |
|
269 | + if (is_null($file)) { |
|
270 | + throw new Exception("Missing parameter for rm!"); |
|
271 | + } |
|
265 | 272 | |
266 | - if (file_exists($file) && !$recursive) |
|
267 | - unlink($file); |
|
268 | - elseif (is_dir($file) && $recursive) |
|
273 | + if (file_exists($file) && !$recursive) { |
|
274 | + unlink($file); |
|
275 | + } elseif (is_dir($file) && $recursive) |
|
269 | 276 | { |
270 | 277 | $that = $this; |
271 | 278 | |
@@ -294,14 +301,15 @@ discard block |
||
294 | 301 | { |
295 | 302 | $recursive = (is_null($recursive)) ? false : $recursive; |
296 | 303 | |
297 | - if (empty($file) || empty($dest)) |
|
298 | - throw new Exception("Missing parameters!"); |
|
304 | + if (empty($file) || empty($dest)) { |
|
305 | + throw new Exception("Missing parameters!"); |
|
306 | + } |
|
299 | 307 | |
300 | 308 | if (is_dir($dest)) |
301 | 309 | { |
302 | - if (!$recursive) |
|
303 | - copy($file, $dest.'/'.$file); |
|
304 | - else { |
|
310 | + if (!$recursive) { |
|
311 | + copy($file, $dest.'/'.$file); |
|
312 | + } else { |
|
305 | 313 | |
306 | 314 | $files = array(); |
307 | 315 | $files[0] = array(); |
@@ -319,20 +327,22 @@ discard block |
||
319 | 327 | |
320 | 328 | foreach ($files[1] as $item) |
321 | 329 | { |
322 | - if (!file_exists($dest.'/'.$item)) |
|
323 | - mkdir("$dest/$item", 0777, true); |
|
330 | + if (!file_exists($dest.'/'.$item)) { |
|
331 | + mkdir("$dest/$item", 0777, true); |
|
332 | + } |
|
324 | 333 | } |
325 | 334 | |
326 | 335 | foreach ($files[0] as $item) |
327 | 336 | { |
328 | - if (!file_exists("$dest/$files")) |
|
329 | - copy($item, $dest.'/'.$item); |
|
337 | + if (!file_exists("$dest/$files")) { |
|
338 | + copy($item, $dest.'/'.$item); |
|
339 | + } |
|
330 | 340 | } |
331 | 341 | }); |
332 | 342 | } |
343 | + } else { |
|
344 | + copy($file, $dest); |
|
333 | 345 | } |
334 | - else |
|
335 | - copy($file, $dest); |
|
336 | 346 | |
337 | 347 | return true; |
338 | 348 | } |
@@ -347,17 +357,21 @@ discard block |
||
347 | 357 | */ |
348 | 358 | public function mv($oldfile, $newfile) |
349 | 359 | { |
350 | - if (empty($oldfile)) |
|
351 | - throw new Exception("Missing parameter for mv!"); |
|
360 | + if (empty($oldfile)) { |
|
361 | + throw new Exception("Missing parameter for mv!"); |
|
362 | + } |
|
352 | 363 | |
353 | - if (is_dir($newfile)) |
|
354 | - $newfile .= '/'.basename($oldfile); |
|
364 | + if (is_dir($newfile)) { |
|
365 | + $newfile .= '/'.basename($oldfile); |
|
366 | + } |
|
355 | 367 | |
356 | - if ($oldfile == $newfile) |
|
357 | - return $this; |
|
368 | + if ($oldfile == $newfile) { |
|
369 | + return $this; |
|
370 | + } |
|
358 | 371 | |
359 | - if(!rename($oldfile, $newfile)) |
|
360 | - return false; |
|
372 | + if(!rename($oldfile, $newfile)) { |
|
373 | + return false; |
|
374 | + } |
|
361 | 375 | |
362 | 376 | return true; |
363 | 377 | } |
@@ -373,21 +387,24 @@ discard block |
||
373 | 387 | */ |
374 | 388 | public function mkdir($dir, $dest = null, $recursive = null) |
375 | 389 | { |
376 | - if (empty($dir)) |
|
377 | - throw new Exception("Missing parameter for mkdir!"); |
|
390 | + if (empty($dir)) { |
|
391 | + throw new Exception("Missing parameter for mkdir!"); |
|
392 | + } |
|
378 | 393 | |
379 | - if (empty($dest)) |
|
380 | - $dest = '.'; |
|
394 | + if (empty($dest)) { |
|
395 | + $dest = '.'; |
|
396 | + } |
|
381 | 397 | |
382 | 398 | $recursive = (is_null($recursive)) ? false : $recursive; |
383 | 399 | |
384 | - if ($recursive) |
|
385 | - mkdir("$dest/$dir", 0777, true); |
|
386 | - else { |
|
400 | + if ($recursive) { |
|
401 | + mkdir("$dest/$dir", 0777, true); |
|
402 | + } else { |
|
387 | 403 | if (!is_dir($dir)) |
388 | 404 | { |
389 | - if(!mkdir("$dir", 0777)) |
|
390 | - return false; |
|
405 | + if(!mkdir("$dir", 0777)) { |
|
406 | + return false; |
|
407 | + } |
|
391 | 408 | } |
392 | 409 | } |
393 | 410 | return true; |
@@ -402,12 +419,14 @@ discard block |
||
402 | 419 | */ |
403 | 420 | public function rmdir($dir) |
404 | 421 | { |
405 | - if (is_null($dir) || empty($dir)) |
|
406 | - throw new Exception("Missing parameter for rmdir!"); |
|
422 | + if (is_null($dir) || empty($dir)) { |
|
423 | + throw new Exception("Missing parameter for rmdir!"); |
|
424 | + } |
|
407 | 425 | |
408 | - if (rmdir($dir)) |
|
409 | - return true; |
|
410 | - else |
|
411 | - return false; |
|
426 | + if (rmdir($dir)) { |
|
427 | + return true; |
|
428 | + } else { |
|
429 | + return false; |
|
430 | + } |
|
412 | 431 | } |
413 | 432 | } |
414 | 433 | \ No newline at end of file |
@@ -17,67 +17,67 @@ |
||
17 | 17 | */ |
18 | 18 | interface ShellInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * Prints the name of current/workinf directory |
|
22 | - */ |
|
23 | - public function pwd(); |
|
20 | + /** |
|
21 | + * Prints the name of current/workinf directory |
|
22 | + */ |
|
23 | + public function pwd(); |
|
24 | 24 | |
25 | - /** |
|
26 | - * Lists all directory contents |
|
27 | - * |
|
28 | - * @param string $path |
|
29 | - */ |
|
30 | - public function ls($path); |
|
25 | + /** |
|
26 | + * Lists all directory contents |
|
27 | + * |
|
28 | + * @param string $path |
|
29 | + */ |
|
30 | + public function ls($path); |
|
31 | 31 | |
32 | - /** |
|
33 | - * Changes the current/working directory |
|
34 | - * |
|
35 | - * @param string $path |
|
36 | - */ |
|
37 | - public function cd($path); |
|
32 | + /** |
|
33 | + * Changes the current/working directory |
|
34 | + * |
|
35 | + * @param string $path |
|
36 | + */ |
|
37 | + public function cd($path); |
|
38 | 38 | |
39 | - /** |
|
40 | - * Creates a file |
|
41 | - * |
|
42 | - * @param string $file |
|
43 | - */ |
|
44 | - public function touch($file); |
|
39 | + /** |
|
40 | + * Creates a file |
|
41 | + * |
|
42 | + * @param string $file |
|
43 | + */ |
|
44 | + public function touch($file); |
|
45 | 45 | |
46 | - /** |
|
47 | - * Deletes files or directories |
|
48 | - * |
|
49 | - * @param string $file |
|
50 | - */ |
|
51 | - public function rm($file); |
|
46 | + /** |
|
47 | + * Deletes files or directories |
|
48 | + * |
|
49 | + * @param string $file |
|
50 | + */ |
|
51 | + public function rm($file); |
|
52 | 52 | |
53 | - /** |
|
54 | - * Prints the name of current/workinf directory |
|
55 | - * |
|
56 | - * @param string $source |
|
57 | - * @param string $dest |
|
58 | - */ |
|
59 | - public function cp($source, $dest); |
|
53 | + /** |
|
54 | + * Prints the name of current/workinf directory |
|
55 | + * |
|
56 | + * @param string $source |
|
57 | + * @param string $dest |
|
58 | + */ |
|
59 | + public function cp($source, $dest); |
|
60 | 60 | |
61 | - /** |
|
62 | - * Moves or renames files |
|
63 | - * |
|
64 | - * @param string $oldfile |
|
65 | - * @param string $newfile |
|
66 | - */ |
|
67 | - public function mv($oldfile, $newfile); |
|
61 | + /** |
|
62 | + * Moves or renames files |
|
63 | + * |
|
64 | + * @param string $oldfile |
|
65 | + * @param string $newfile |
|
66 | + */ |
|
67 | + public function mv($oldfile, $newfile); |
|
68 | 68 | |
69 | - /** |
|
70 | - * Creates directories |
|
71 | - * |
|
72 | - * @param string $dir |
|
73 | - * @param string $dest |
|
74 | - */ |
|
75 | - public function mkdir($dir, $dest); |
|
69 | + /** |
|
70 | + * Creates directories |
|
71 | + * |
|
72 | + * @param string $dir |
|
73 | + * @param string $dest |
|
74 | + */ |
|
75 | + public function mkdir($dir, $dest); |
|
76 | 76 | |
77 | - /** |
|
78 | - * Deletes empty directories |
|
79 | - * |
|
80 | - * @param string $dir |
|
81 | - */ |
|
82 | - public function rmdir($dir); |
|
77 | + /** |
|
78 | + * Deletes empty directories |
|
79 | + * |
|
80 | + * @param string $dir |
|
81 | + */ |
|
82 | + public function rmdir($dir); |
|
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -108,8 +108,9 @@ discard block |
||
108 | 108 | |
109 | 109 | foreach ($attribs[$label] as $attrib) |
110 | 110 | { |
111 | - if ($attrib->getName() == $name) |
|
112 | - return $attrib; |
|
111 | + if ($attrib->getName() == $name) { |
|
112 | + return $attrib; |
|
113 | + } |
|
113 | 114 | } |
114 | 115 | } |
115 | 116 | |
@@ -129,12 +130,12 @@ discard block |
||
129 | 130 | if (array_key_exists($label, $attribs)) |
130 | 131 | { |
131 | 132 | |
132 | - if (!array_key_exists($name, $attribs)) |
|
133 | - $this->attributes[$label][] = new Attribute($name, $value); |
|
134 | - else |
|
135 | - $this->getAttribute($label, $name)->setValue($value); |
|
136 | - } |
|
137 | - else { |
|
133 | + if (!array_key_exists($name, $attribs)) { |
|
134 | + $this->attributes[$label][] = new Attribute($name, $value); |
|
135 | + } else { |
|
136 | + $this->getAttribute($label, $name)->setValue($value); |
|
137 | + } |
|
138 | + } else { |
|
138 | 139 | $this->attributes[$label][] = new Attribute($name, $value); |
139 | 140 | } |
140 | 141 | } |
@@ -166,8 +167,9 @@ discard block |
||
166 | 167 | */ |
167 | 168 | public function __construct($options) |
168 | 169 | { |
169 | - if (!array_key_exists('endTag', $options)) |
|
170 | - $this->setEndTag(false); |
|
170 | + if (!array_key_exists('endTag', $options)) { |
|
171 | + $this->setEndTag(false); |
|
172 | + } |
|
171 | 173 | |
172 | 174 | foreach ($options as $key => $value) |
173 | 175 | { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | throw new \RuntimeException("Could not create the socket"); |
121 | 121 | } |
122 | - } |
|
122 | + } |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Binds the socket |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return bool |
145 | 145 | */ |
146 | - public function close() |
|
147 | - { |
|
146 | + public function close() |
|
147 | + { |
|
148 | 148 | return socket_close($this->socket); |
149 | - } |
|
149 | + } |
|
150 | 150 | } |
151 | 151 | \ No newline at end of file |
@@ -108,8 +108,8 @@ |
||
108 | 108 | { |
109 | 109 | foreach ($options as $option => $value) |
110 | 110 | { |
111 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
112 | - $this->{'set'.$option}($value); |
|
111 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set' . $option)) |
|
112 | + $this->{'set' . $option}($value); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | if (!($this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) |
@@ -108,8 +108,9 @@ |
||
108 | 108 | { |
109 | 109 | foreach ($options as $option => $value) |
110 | 110 | { |
111 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
112 | - $this->{'set'.$option}($value); |
|
111 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) { |
|
112 | + $this->{'set'.$option}($value); |
|
113 | + } |
|
113 | 114 | } |
114 | 115 | |
115 | 116 | if (!($this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string |
28 | 28 | */ |
29 | - public function read($socket) |
|
30 | - { |
|
31 | - if (($message = @socket_read($socket, 1024)) === false) |
|
32 | - { |
|
33 | - $errno = socket_last_error(); |
|
34 | - $this->error($errno, socket_strerror($errno)); |
|
29 | + public function read($socket) |
|
30 | + { |
|
31 | + if (($message = @socket_read($socket, 1024)) === false) |
|
32 | + { |
|
33 | + $errno = socket_last_error(); |
|
34 | + $this->error($errno, socket_strerror($errno)); |
|
35 | 35 | |
36 | - throw new \RuntimeException("Could not read message from client socket"); |
|
37 | - } |
|
36 | + throw new \RuntimeException("Could not read message from client socket"); |
|
37 | + } |
|
38 | 38 | |
39 | - return $message; |
|
40 | - } |
|
39 | + return $message; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Sends a message to client socket |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return integer |
51 | 51 | */ |
52 | - public function send($socket, $message) |
|
53 | - { |
|
54 | - if (($bytes = @socket_write($socket, $message, strlen($message))) === false) |
|
55 | - { |
|
56 | - $errno = socket_last_error(); |
|
57 | - $this->error($errno, socket_strerror($errno)); |
|
52 | + public function send($socket, $message) |
|
53 | + { |
|
54 | + if (($bytes = @socket_write($socket, $message, strlen($message))) === false) |
|
55 | + { |
|
56 | + $errno = socket_last_error(); |
|
57 | + $this->error($errno, socket_strerror($errno)); |
|
58 | 58 | |
59 | - throw new \RuntimeException("Could not send message to the client socket"); |
|
60 | - } |
|
59 | + throw new \RuntimeException("Could not send message to the client socket"); |
|
60 | + } |
|
61 | 61 | |
62 | - return $bytes; |
|
63 | - } |
|
62 | + return $bytes; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Sets socket to listening |
@@ -71,54 +71,54 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return null |
73 | 73 | */ |
74 | - public function listen(Array $eventHandlers = array()) |
|
75 | - { |
|
76 | - $event = $eventHandlers; |
|
77 | - $clousure = function(){}; |
|
74 | + public function listen(Array $eventHandlers = array()) |
|
75 | + { |
|
76 | + $event = $eventHandlers; |
|
77 | + $clousure = function(){}; |
|
78 | 78 | |
79 | - if (!array_key_exists('success', $event)) |
|
80 | - $event["success"] = $clousure; |
|
79 | + if (!array_key_exists('success', $event)) |
|
80 | + $event["success"] = $clousure; |
|
81 | 81 | |
82 | - if (!array_key_exists('error', $event)) |
|
83 | - $event["error"] = $clousure; |
|
82 | + if (!array_key_exists('error', $event)) |
|
83 | + $event["error"] = $clousure; |
|
84 | 84 | |
85 | - $listener = false; |
|
85 | + $listener = false; |
|
86 | 86 | |
87 | - if (!($listener = @socket_listen($this->socket, 30))) |
|
88 | - { |
|
89 | - $errno = socket_last_error(); |
|
90 | - $this->error($errno, socket_strerror($errno)); |
|
87 | + if (!($listener = @socket_listen($this->socket, 30))) |
|
88 | + { |
|
89 | + $errno = socket_last_error(); |
|
90 | + $this->error($errno, socket_strerror($errno)); |
|
91 | 91 | |
92 | - throw new \RuntimeException("Could not set socket to listen"); |
|
93 | - } |
|
94 | - else { |
|
92 | + throw new \RuntimeException("Could not set socket to listen"); |
|
93 | + } |
|
94 | + else { |
|
95 | 95 | |
96 | - echo "\n"; |
|
97 | - echo "Server Started : " . date('Y-m-d H:i:s') . "\n"; |
|
98 | - echo "Master socket : " . $this->socket . "\n"; |
|
99 | - echo "Listening on : " . $this->host . " port " . $this->port . "\n\n"; |
|
96 | + echo "\n"; |
|
97 | + echo "Server Started : " . date('Y-m-d H:i:s') . "\n"; |
|
98 | + echo "Master socket : " . $this->socket . "\n"; |
|
99 | + echo "Listening on : " . $this->host . " port " . $this->port . "\n\n"; |
|
100 | 100 | |
101 | - $socket = $this->socket; |
|
101 | + $socket = $this->socket; |
|
102 | 102 | |
103 | - if (!($spawn = @socket_accept($this->socket))) |
|
104 | - { |
|
105 | - $errno = socket_last_error(); |
|
106 | - $this->error($errno, socket_strerror($errno)); |
|
103 | + if (!($spawn = @socket_accept($this->socket))) |
|
104 | + { |
|
105 | + $errno = socket_last_error(); |
|
106 | + $this->error($errno, socket_strerror($errno)); |
|
107 | 107 | |
108 | - throw new \RuntimeException("Could not accept incoming connection"); |
|
109 | - } |
|
108 | + throw new \RuntimeException("Could not accept incoming connection"); |
|
109 | + } |
|
110 | 110 | |
111 | - $input = $this->read($spawn); |
|
111 | + $input = $this->read($spawn); |
|
112 | 112 | |
113 | - $input = trim($input); |
|
114 | - call_user_func($event["success"], $input, $this, $spawn); |
|
113 | + $input = trim($input); |
|
114 | + call_user_func($event["success"], $input, $this, $spawn); |
|
115 | 115 | |
116 | - socket_close($spawn); |
|
117 | - } |
|
116 | + socket_close($spawn); |
|
117 | + } |
|
118 | 118 | |
119 | - if (!$listener) |
|
120 | - call_user_func($event["error"], $this->getLastError()); |
|
119 | + if (!$listener) |
|
120 | + call_user_func($event["error"], $this->getLastError()); |
|
121 | 121 | |
122 | - return $listener; |
|
123 | - } |
|
122 | + return $listener; |
|
123 | + } |
|
124 | 124 | } |
125 | 125 | \ No newline at end of file |
@@ -74,7 +74,7 @@ |
||
74 | 74 | public function listen(Array $eventHandlers = array()) |
75 | 75 | { |
76 | 76 | $event = $eventHandlers; |
77 | - $clousure = function(){}; |
|
77 | + $clousure = function() {}; |
|
78 | 78 | |
79 | 79 | if (!array_key_exists('success', $event)) |
80 | 80 | $event["success"] = $clousure; |
@@ -76,11 +76,13 @@ discard block |
||
76 | 76 | $event = $eventHandlers; |
77 | 77 | $clousure = function(){}; |
78 | 78 | |
79 | - if (!array_key_exists('success', $event)) |
|
80 | - $event["success"] = $clousure; |
|
79 | + if (!array_key_exists('success', $event)) { |
|
80 | + $event["success"] = $clousure; |
|
81 | + } |
|
81 | 82 | |
82 | - if (!array_key_exists('error', $event)) |
|
83 | - $event["error"] = $clousure; |
|
83 | + if (!array_key_exists('error', $event)) { |
|
84 | + $event["error"] = $clousure; |
|
85 | + } |
|
84 | 86 | |
85 | 87 | $listener = false; |
86 | 88 | |
@@ -90,8 +92,7 @@ discard block |
||
90 | 92 | $this->error($errno, socket_strerror($errno)); |
91 | 93 | |
92 | 94 | throw new \RuntimeException("Could not set socket to listen"); |
93 | - } |
|
94 | - else { |
|
95 | + } else { |
|
95 | 96 | |
96 | 97 | echo "\n"; |
97 | 98 | echo "Server Started : " . date('Y-m-d H:i:s') . "\n"; |
@@ -116,8 +117,9 @@ discard block |
||
116 | 117 | socket_close($spawn); |
117 | 118 | } |
118 | 119 | |
119 | - if (!$listener) |
|
120 | - call_user_func($event["error"], $this->getLastError()); |
|
120 | + if (!$listener) { |
|
121 | + call_user_func($event["error"], $this->getLastError()); |
|
122 | + } |
|
121 | 123 | |
122 | 124 | return $listener; |
123 | 125 | } |
@@ -127,8 +127,9 @@ |
||
127 | 127 | { |
128 | 128 | $codes = $this->httpStatusCodes; |
129 | 129 | |
130 | - if (!in_array($code, array_keys($codes))) |
|
131 | - throw new \LogicException("Status code not supported"); |
|
130 | + if (!in_array($code, array_keys($codes))) { |
|
131 | + throw new \LogicException("Status code not supported"); |
|
132 | + } |
|
132 | 133 | |
133 | 134 | return $this->httpStatusCodes[$code]; |
134 | 135 | } |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | $ht = $this->http; |
30 | 30 | |
31 | 31 | $this->http->writeStatus($ht::HTTP_UNAUTHORIZED); |
32 | - header('WWW-Authenticate: Basic realm="'.$this->realm.'"'); |
|
33 | - die('Error ' . $ht::HTTP_UNAUTHORIZED .' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
32 | + header('WWW-Authenticate: Basic realm="' . $this->realm . '"'); |
|
33 | + die('Error ' . $ht::HTTP_UNAUTHORIZED . ' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | public function response() |
77 | 77 | { |
78 | 78 | $status = http_response_code(); |
79 | - $this->response = 'Error ' . $status .' (' . $this->http->getStatusText($status) . ')!!'; |
|
79 | + $this->response = 'Error ' . $status . ' (' . $this->http->getStatusText($status) . ')!!'; |
|
80 | 80 | echo $this->response; |
81 | 81 | } |
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | $ht = $this->http; |
30 | 30 | |
31 | 31 | $this->http->writeStatus($ht::HTTP_UNAUTHORIZED); |
32 | - header('WWW-Authenticate: Digest realm="'.$this->realm.'",qop="auth",nonce="'.uniqid().'",opaque="'.md5($this->realm).'"'); |
|
33 | - die('Error ' . $ht::HTTP_UNAUTHORIZED .' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
32 | + header('WWW-Authenticate: Digest realm="' . $this->realm . '",qop="auth",nonce="' . uniqid() . '",opaque="' . md5($this->realm) . '"'); |
|
33 | + die('Error ' . $ht::HTTP_UNAUTHORIZED . ' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | $A1 = md5($data['username'] . ':' . $this->realm . ':' . $this->whiteList[$data['username']]); |
53 | - $A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']); |
|
54 | - $valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2); |
|
53 | + $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']); |
|
54 | + $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2); |
|
55 | 55 | |
56 | 56 | if ($data['response'] != $valid_response) |
57 | 57 | { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | public function response() |
98 | 98 | { |
99 | 99 | $status = http_response_code(); |
100 | - $this->response = 'Error ' . $status .' (' . $this->http->getStatusText($status) . ')!!'; |
|
100 | + $this->response = 'Error ' . $status . ' (' . $this->http->getStatusText($status) . ')!!'; |
|
101 | 101 | echo $this->response; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | \ No newline at end of file |