1 | <?php |
||
23 | class Source |
||
24 | { |
||
25 | /** |
||
26 | * Run a simulation |
||
27 | * |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $isSimulation; |
||
31 | |||
32 | /** |
||
33 | * Executes the backup and compression. |
||
34 | * |
||
35 | * @param \phpbu\App\Backup\Source $source |
||
36 | * @param \phpbu\App\Backup\Target $target |
||
37 | * @param \phpbu\App\Result $result |
||
38 | * @param bool $simulate |
||
39 | * @throws \phpbu\App\Exception |
||
40 | */ |
||
41 | public function run(SourceExe $source, Target $target, Result $result, $simulate) |
||
47 | |||
48 | /** |
||
49 | * Executes the backup and compression. |
||
50 | * |
||
51 | * @param \phpbu\App\Backup\Source $source |
||
52 | * @param \phpbu\App\Backup\Target $target |
||
53 | * @param \phpbu\App\Result $result |
||
54 | * @throws \phpbu\App\Exception |
||
55 | */ |
||
56 | protected function backup(SourceExe $source, Target $target, Result $result) |
||
61 | |||
62 | /** |
||
63 | * Simulates the backup. |
||
64 | * |
||
65 | * @param \phpbu\App\Backup\Source $source |
||
66 | * @param \phpbu\App\Backup\Target $target |
||
67 | * @param \phpbu\App\Result $result |
||
68 | * @throws \phpbu\App\Exception |
||
69 | */ |
||
70 | protected function simulate(SourceExe $source, Target $target, Result $result) |
||
77 | |||
78 | /** |
||
79 | * Compress the backup if the source did not handle the compression. |
||
80 | * |
||
81 | * @param \phpbu\App\Backup\Source\Status $status |
||
82 | * @param \phpbu\App\Backup\Target $target |
||
83 | * @param \phpbu\App\Result $result |
||
84 | * @throws \phpbu\App\Exception |
||
85 | */ |
||
86 | protected function compress(Status $status, Target $target, Result $result) |
||
92 | |||
93 | /** |
||
94 | * Handle directory compression for sources which can't handle compression by them self. |
||
95 | * |
||
96 | * @param \phpbu\App\Backup\Target $target |
||
97 | * @param \phpbu\App\Result $result |
||
98 | * @param string $dataToCompress |
||
99 | * @throws \phpbu\App\Exception |
||
100 | */ |
||
101 | private function handleCompression(Target $target, Result $result, $dataToCompress) |
||
110 | |||
111 | /** |
||
112 | * Compresses the target if the target is a directory. |
||
113 | * |
||
114 | * @param \phpbu\App\Backup\Target $target |
||
115 | * @param \phpbu\App\Result $result |
||
116 | * @param string $dataToCompress |
||
117 | * @throws \phpbu\App\Exception |
||
118 | */ |
||
119 | private function compressDirectory(Target $target, Result $result, $dataToCompress) |
||
130 | |||
131 | /** |
||
132 | * Compresses the target if the target is a single file. |
||
133 | * |
||
134 | * @param \phpbu\App\Backup\Target $target |
||
135 | * @param \phpbu\App\Result $result |
||
136 | * @param string $dataToCompress |
||
137 | * @throws \phpbu\App\Exception |
||
138 | */ |
||
139 | private function compressFile(Target $target, Result $result, $dataToCompress) |
||
144 | |||
145 | /** |
||
146 | * Execute the compressor. |
||
147 | * Returns the path to the created archive file. |
||
148 | * |
||
149 | * @param \phpbu\App\Backup\Compressor\Executable $compressor |
||
150 | * @param \phpbu\App\Backup\Target $target |
||
151 | * @param \phpbu\App\Result $result |
||
152 | * @return string |
||
153 | */ |
||
154 | private function executeCompressor(Compressor\Executable $compressor, Target $target, Result $result) |
||
164 | } |
||
165 |