1 | <?php |
||
22 | class Check extends Abstraction |
||
23 | { |
||
24 | /** |
||
25 | * Failure state of all executed Checks. |
||
26 | * |
||
27 | * @var boolean |
||
28 | */ |
||
29 | private $failure = false; |
||
30 | |||
31 | /** |
||
32 | * Executes a backup check. |
||
33 | * |
||
34 | * @param \phpbu\App\Backup\Check $check |
||
35 | * @param \phpbu\App\Configuration\Backup\Check $config |
||
36 | * @param \phpbu\App\Backup\Target $target |
||
37 | * @param \phpbu\App\Backup\Collector $collector |
||
38 | * @param \phpbu\App\Result $result |
||
39 | */ |
||
40 | 3 | public function run(CheckExe $check, CheckConfig $config, Target $target, Collector $collector, Result $result) |
|
41 | { |
||
42 | try { |
||
43 | 3 | $result->checkStart($config); |
|
44 | |||
45 | 3 | if ($this->runCheck($check, $config->value, $target, $collector)) { |
|
46 | 1 | $result->checkEnd($config); |
|
47 | 1 | } else { |
|
48 | 1 | $this->failure = true; |
|
49 | 1 | $result->checkFailed($config); |
|
50 | } |
||
51 | 3 | } catch (Exception $e) { |
|
52 | 1 | $this->failure = true; |
|
53 | 1 | $result->addError($e); |
|
54 | 1 | $result->checkFailed($config); |
|
55 | } |
||
56 | 3 | } |
|
57 | |||
58 | /** |
||
59 | * Return true if the last check did fail. |
||
60 | * |
||
61 | * @return boolean |
||
62 | */ |
||
63 | 3 | public function hasFailed() |
|
67 | |||
68 | /** |
||
69 | * Executes the actual check. |
||
70 | * |
||
71 | * @param \phpbu\App\Backup\Check $check |
||
72 | * @param string $value |
||
73 | * @param \phpbu\App\Backup\Target $target |
||
74 | * @param \phpbu\App\Backup\Collector $collector |
||
75 | * @return bool |
||
76 | */ |
||
77 | protected function runCheck(CheckExe $check, $value, Target $target, Collector $collector) |
||
81 | } |
||
82 |