Conditions | 6 |
Paths | 7 |
Total Lines | 31 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 7.5145 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
31 | 13 | public function __construct(AppConfig $appConfig, ILogger $logger){ |
|
32 | 13 | $this->appConfig = $appConfig; |
|
33 | 13 | $this->logger = $logger; |
|
34 | try { |
||
35 | 13 | $avMode = $appConfig->getAvMode(); |
|
36 | switch ($avMode) { |
||
37 | 13 | case 'daemon': |
|
38 | 7 | $this->scannerClass = 'OCA\Files_Antivirus\Scanner\Daemon'; |
|
39 | 7 | break; |
|
40 | 7 | case 'socket': |
|
41 | 1 | $this->scannerClass = 'OCA\Files_Antivirus\Scanner\Socket'; |
|
42 | 1 | break; |
|
43 | 6 | case 'executable': |
|
44 | 6 | $this->scannerClass = 'OCA\Files_Antivirus\Scanner\Local'; |
|
45 | 6 | break; |
|
46 | default: |
||
47 | throw new InitException( |
||
48 | sprintf( |
||
49 | 'Please check the settings at the admin page. Invalid mode: "%s"', |
||
50 | 13 | $avMode |
|
51 | ) |
||
52 | ); |
||
53 | } |
||
54 | } catch (InitException $e) { |
||
55 | // rethrow misconfiguration exception |
||
56 | throw $e; |
||
57 | } catch (\Exception $e) { |
||
58 | $message = implode(' ', [ __CLASS__, __METHOD__, $e->getMessage()]); |
||
59 | $this->logger->warning($message, ['app' => 'files_antivirus']); |
||
60 | } |
||
61 | 13 | } |
|
62 | |||
71 |