1
|
|
|
<?php |
2
|
|
|
namespace phpbu\App\Runner; |
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 http://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
|
|
|
public function run(CheckExe $check, Target $target, $value, Collector $collector, Result $result) |
34
|
|
|
{ |
35
|
|
|
return $this->isSimulation() |
36
|
|
|
? $this->simulate($check, $target, $value, $collector, $result) |
37
|
|
|
: $this->runCheck($check, $target, $value, $collector, $result); |
38
|
|
|
} |
39
|
|
|
|
40
|
3 |
|
/** |
41
|
|
|
* Execute the backup check. |
42
|
|
|
* |
43
|
3 |
|
* @param \phpbu\App\Backup\Check $check |
44
|
|
|
* @param \phpbu\App\Backup\Target $target |
45
|
3 |
|
* @param mixed $value |
46
|
1 |
|
* @param \phpbu\App\Backup\Collector $collector |
47
|
1 |
|
* @param \phpbu\App\Result $result |
48
|
1 |
|
* @return bool |
49
|
1 |
|
*/ |
50
|
|
|
protected function runCheck(CheckExe $check, Target $target, $value, Collector $collector, Result $result) |
51
|
3 |
|
{ |
52
|
1 |
|
return $check->pass($target, $value, $collector, $result); |
53
|
1 |
|
} |
54
|
1 |
|
|
55
|
|
|
/** |
56
|
3 |
|
* 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
|
3 |
|
* @return bool |
64
|
|
|
*/ |
65
|
3 |
|
protected function simulate(CheckExe $check, Target $target, $value, Collector $collector, Result $result) |
66
|
|
|
{ |
67
|
|
|
return ($check instanceof Simulator) ? $check->simulate($target, $value, $collector, $result) : true; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|