|
1
|
|
|
<?php |
|
2
|
|
|
namespace phpbu\App\Runner\Backup; |
|
3
|
|
|
|
|
4
|
|
|
use phpbu\App\Backup\Check as CheckExe; |
|
5
|
|
|
use phpbu\App\Backup\Check\Simulator; |
|
6
|
|
|
use phpbu\App\Backup\Collector; |
|
7
|
|
|
use phpbu\App\Backup\Target; |
|
8
|
|
|
use phpbu\App\Result; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Check Runner class. |
|
12
|
|
|
* |
|
13
|
|
|
* @package phpbu |
|
14
|
|
|
* @subpackage App |
|
15
|
|
|
* @author Sebastian Feldmann <[email protected]> |
|
16
|
|
|
* @copyright Sebastian Feldmann <[email protected]> |
|
17
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
|
18
|
|
|
* @link https://phpbu.de/ |
|
19
|
|
|
* @since Class available since Release 3.0.0 |
|
20
|
|
|
*/ |
|
21
|
|
|
class Check extends Abstraction |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Executes or simulate backup check. |
|
25
|
|
|
* |
|
26
|
|
|
* @param \phpbu\App\Backup\Check $check |
|
27
|
|
|
* @param \phpbu\App\Backup\Target $target |
|
28
|
|
|
* @param mixed $value |
|
29
|
|
|
* @param \phpbu\App\Backup\Collector $collector |
|
30
|
|
|
* @param \phpbu\App\Result $result |
|
31
|
|
|
* @return bool |
|
32
|
|
|
*/ |
|
33
|
4 |
|
public function run(CheckExe $check, Target $target, $value, Collector $collector, Result $result) : bool |
|
34
|
|
|
{ |
|
35
|
4 |
|
return $this->isSimulation() |
|
36
|
2 |
|
? $this->simulate($check, $target, $value, $collector, $result) |
|
37
|
4 |
|
: $this->runCheck($check, $target, $value, $collector, $result); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Execute the backup check. |
|
42
|
|
|
* |
|
43
|
|
|
* @param \phpbu\App\Backup\Check $check |
|
44
|
|
|
* @param \phpbu\App\Backup\Target $target |
|
45
|
|
|
* @param mixed $value |
|
46
|
|
|
* @param \phpbu\App\Backup\Collector $collector |
|
47
|
|
|
* @param \phpbu\App\Result $result |
|
48
|
|
|
* @return bool |
|
49
|
|
|
*/ |
|
50
|
2 |
|
protected function runCheck(CheckExe $check, Target $target, $value, Collector $collector, Result $result) : bool |
|
51
|
|
|
{ |
|
52
|
2 |
|
return $check->pass($target, $value, $collector, $result); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Simulate the backup check. |
|
57
|
|
|
* |
|
58
|
|
|
* @param \phpbu\App\Backup\Check $check |
|
59
|
|
|
* @param \phpbu\App\Backup\Target $target |
|
60
|
|
|
* @param mixed $value |
|
61
|
|
|
* @param \phpbu\App\Backup\Collector $collector |
|
62
|
|
|
* @param \phpbu\App\Result $result |
|
63
|
|
|
* @return bool |
|
64
|
|
|
*/ |
|
65
|
2 |
|
protected function simulate(CheckExe $check, Target $target, $value, Collector $collector, Result $result) : bool |
|
66
|
|
|
{ |
|
67
|
2 |
|
return ($check instanceof Simulator) ? $check->simulate($target, $value, $collector, $result) : true; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|