ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilVirusScannerSetupConfig.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
7
9{
10 const VIRUS_SCANNER_NONE = "none";
11 const VIRUS_SCANNER_SOPHOS = "sophos";
12 const VIRUS_SCANNER_ANTIVIR = "antivir";
13 const VIRUS_SCANNER_CLAMAV = "clamav";
14
18 protected $virus_scanner;
19
23 protected $path_to_scan;
24
28 protected $path_to_clean;
29
30 public function __construct(
31 string $virus_scanner,
32 ?string $path_to_scan,
33 ?string $path_to_clean
34 ) {
35 $scanners = [
40 ];
41 if (!in_array($virus_scanner, $scanners)) {
42 throw new \InvalidArgumentException(
43 "Unknown virus scanner: '$virus_scanner'"
44 );
45 }
46 if ($virus_scanner !== self::VIRUS_SCANNER_NONE && (!$path_to_scan || !$path_to_clean)) {
47 throw new \InvalidArgumentException(
48 "Missing path to scan and/or clean commands for virus scanner."
49 );
50 }
51 $this->virus_scanner = $virus_scanner;
52 $this->path_to_scan = $this->toLinuxConvention($path_to_scan);
53 $this->path_to_clean = $this->toLinuxConvention($path_to_clean);
54 }
55
56 protected function toLinuxConvention(?string $p) : ?string
57 {
58 if (!$p) {
59 return null;
60 }
61 return preg_replace("/\\\\/", "/", $p);
62 }
63
64 public function getVirusScanner() : string
65 {
67 }
68
69 public function getPathToScan() : ?string
70 {
72 }
73
74 public function getPathToClean() : ?string
75 {
77 }
78}
An exception for terminatinating execution or to throw for unit testing.
A password is used as part of credentials for authentication.
Definition: Password.php:14
__construct(string $virus_scanner, ?string $path_to_scan, ?string $path_to_clean)
A configuration for the setup.
Definition: Config.php:11