|
1
|
|
|
<?php |
|
2
|
|
|
namespace phpbu\App\Runner\Backup; |
|
3
|
|
|
|
|
4
|
|
|
use phpbu\App\Backup\Cleaner as CleanerExe; |
|
5
|
|
|
use phpbu\App\Backup\Cleaner\Simulator; |
|
6
|
|
|
use phpbu\App\Backup\Collector; |
|
7
|
|
|
use phpbu\App\Backup\Target; |
|
8
|
|
|
use phpbu\App\Result; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Cleaner Runner |
|
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 Cleaner extends Abstraction |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Execute or simulate the cleanup. |
|
25
|
|
|
* |
|
26
|
|
|
* @param \phpbu\App\Backup\Cleaner $cleaner |
|
27
|
|
|
* @param \phpbu\App\Backup\Target $target |
|
28
|
|
|
* @param \phpbu\App\Backup\Collector $collector |
|
29
|
|
|
* @param \phpbu\App\Result $result |
|
30
|
|
|
*/ |
|
31
|
3 |
|
public function run(CleanerExe $cleaner, Target $target, Collector $collector, Result $result) |
|
32
|
|
|
{ |
|
33
|
3 |
|
$this->isSimulation() |
|
34
|
1 |
|
? $this->simulate($cleaner, $target, $collector, $result) |
|
35
|
2 |
|
: $this->clean($cleaner, $target, $collector, $result); |
|
36
|
2 |
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Execute the cleanup. |
|
40
|
|
|
* |
|
41
|
|
|
* @param \phpbu\App\Backup\Cleaner $cleaner |
|
42
|
|
|
* @param \phpbu\App\Backup\Target $target |
|
43
|
|
|
* @param \phpbu\App\Backup\Collector $collector |
|
44
|
|
|
* @param \phpbu\App\Result $result |
|
45
|
|
|
*/ |
|
46
|
2 |
|
protected function clean(CleanerExe $cleaner, Target $target, Collector $collector, Result $result) |
|
47
|
|
|
{ |
|
48
|
2 |
|
$cleaner->cleanup($target, $collector, $result); |
|
49
|
1 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Simulate the cleanup process. |
|
53
|
|
|
* |
|
54
|
|
|
* @param \phpbu\App\Backup\Cleaner $cleaner |
|
55
|
|
|
* @param \phpbu\App\Backup\Target $target |
|
56
|
|
|
* @param \phpbu\App\Backup\Collector $collector |
|
57
|
|
|
* @param \phpbu\App\Result $result |
|
58
|
|
|
*/ |
|
59
|
1 |
|
protected function simulate(CleanerExe $cleaner, Target $target, Collector $collector, Result $result) |
|
60
|
|
|
{ |
|
61
|
1 |
|
if ($cleaner instanceof Simulator) { |
|
62
|
1 |
|
$cleaner->simulate($target, $collector, $result); |
|
63
|
|
|
} |
|
64
|
1 |
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|