1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace phpbu\App\Backup\Restore; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Plan |
9
|
|
|
* |
10
|
|
|
* @package phpbu |
11
|
|
|
* @subpackage |
12
|
|
|
* @author Sebastian Feldmann <[email protected]> |
13
|
|
|
* @copyright Sebastian Feldmann <[email protected]> |
14
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
15
|
|
|
* @link https://www.phpbu.de/ |
16
|
|
|
* @since Class available since Release 6.0.0 |
17
|
|
|
*/ |
18
|
|
|
class Plan |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* List of commands to execute to restore the backup |
22
|
|
|
* |
23
|
|
|
* @var array |
24
|
|
|
*/ |
25
|
|
|
private $commands = [ |
26
|
|
|
'decrypt' => [], |
27
|
|
|
'decompress' => [], |
28
|
|
|
'restore' => [] |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Is used crypt supported |
33
|
|
|
* |
34
|
|
|
* @var bool |
35
|
|
|
*/ |
36
|
|
|
private $supportedCrypt = true; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Is used source supported |
40
|
|
|
* |
41
|
|
|
* @var bool |
42
|
|
|
*/ |
43
|
|
|
private $supportedSource = true; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Mark the crypt implementation as not supported to restore |
47
|
|
|
* |
48
|
|
|
* @return void |
49
|
|
|
*/ |
50
|
1 |
|
public function markCryptAsUnsupported(): void |
51
|
|
|
{ |
52
|
1 |
|
$this->supportedCrypt = false; |
53
|
1 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Does crypt support restore |
57
|
|
|
* |
58
|
|
|
* @return bool |
59
|
|
|
*/ |
60
|
3 |
|
public function isCryptSupported(): bool |
61
|
|
|
{ |
62
|
3 |
|
return $this->supportedCrypt; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Add a decryption command to the restore plan |
67
|
|
|
* |
68
|
|
|
* @param string $command |
69
|
|
|
* @return void |
70
|
|
|
*/ |
71
|
3 |
|
public function addDecryptionCommand(string $command): void |
72
|
|
|
{ |
73
|
3 |
|
$this->commands['decrypt'][] = $command; |
74
|
3 |
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Return the list of decryption commands |
78
|
|
|
* |
79
|
|
|
* @return array |
80
|
|
|
*/ |
81
|
5 |
|
public function getDecryptionCommands(): array |
82
|
|
|
{ |
83
|
5 |
|
return $this->commands['decrypt']; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Add an decompression command to the restore plan |
88
|
|
|
* |
89
|
|
|
* @param string $command |
90
|
|
|
* @return void |
91
|
|
|
*/ |
92
|
1 |
|
public function addDecompressionCommand(string $command): void |
93
|
|
|
{ |
94
|
1 |
|
$this->commands['decompress'][] = $command; |
95
|
1 |
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Return the list of decompression commands |
99
|
|
|
* |
100
|
|
|
* @return array |
101
|
|
|
*/ |
102
|
5 |
|
public function getDecompressionCommands(): array |
103
|
|
|
{ |
104
|
5 |
|
return $this->commands['decompress']; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Mark used source as unsupported to restore |
109
|
|
|
* |
110
|
|
|
* @return void |
111
|
|
|
*/ |
112
|
|
|
public function markSourceAsUnsupported(): void |
113
|
|
|
{ |
114
|
|
|
$this->supportedSource = false; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Does the source support restore |
119
|
|
|
* |
120
|
|
|
* @return bool |
121
|
|
|
*/ |
122
|
3 |
|
public function isSourceSupported(): bool |
123
|
|
|
{ |
124
|
3 |
|
return $this->supportedSource; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Add restore command to the restore plan |
129
|
|
|
* |
130
|
|
|
* @param string $command |
131
|
|
|
* @return void |
132
|
|
|
*/ |
133
|
2 |
|
public function addRestoreCommand(string $command): void |
134
|
|
|
{ |
135
|
2 |
|
$this->commands['restore'][] = $command; |
136
|
2 |
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Return the list of restore commands |
140
|
|
|
* |
141
|
|
|
* @return array |
142
|
|
|
*/ |
143
|
5 |
|
public function getRestoreCommands(): array |
144
|
|
|
{ |
145
|
5 |
|
return $this->commands['restore']; |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
|