1 | <?php |
||
19 | trait Compression |
||
20 | { |
||
21 | /** |
||
22 | * Compress the backup if the source did not handle the compression. |
||
23 | * |
||
24 | * @param \phpbu\App\Backup\Source\Status $status |
||
25 | * @param \phpbu\App\Backup\Target $target |
||
26 | * @param \phpbu\App\Result $result |
||
27 | * @throws \phpbu\App\Exception |
||
28 | */ |
||
29 | 12 | protected function compress(Status $status, Target $target, Result $result) |
|
37 | |||
38 | /** |
||
39 | * Handle directory compression for sources which can't handle compression by them self. |
||
40 | * |
||
41 | * @param \phpbu\App\Backup\Target $target |
||
42 | * @param \phpbu\App\Result $result |
||
43 | * @param \phpbu\App\Backup\Source\Status $status |
||
44 | * @throws \phpbu\App\Exception |
||
45 | */ |
||
46 | 3 | protected function handleCompression(Target $target, Result $result, Status $status) |
|
55 | |||
56 | /** |
||
57 | * Compresses the target if the target is a directory. |
||
58 | * |
||
59 | * @param \phpbu\App\Backup\Target $target |
||
60 | * @param \phpbu\App\Result $result |
||
61 | * @param string $dataToCompress |
||
62 | * @throws \phpbu\App\Exception |
||
63 | */ |
||
64 | 2 | protected function compressDirectory(Target $target, Result $result, $dataToCompress) |
|
76 | |||
77 | /** |
||
78 | * Compresses the target if the target is a single file. |
||
79 | * |
||
80 | * @param \phpbu\App\Backup\Target $target |
||
81 | * @param \phpbu\App\Result $result |
||
82 | * @param string $dataToCompress |
||
83 | */ |
||
84 | 2 | protected function compressFile(Target $target, Result $result, $dataToCompress) |
|
89 | |||
90 | /** |
||
91 | * Execute the compressor. |
||
92 | * Returns the path to the created archive file. |
||
93 | * |
||
94 | * @param \phpbu\App\Backup\Compressor\Executable $compressor |
||
95 | * @param \phpbu\App\Backup\Target $target |
||
96 | * @param \phpbu\App\Result $result |
||
97 | * @return string |
||
98 | */ |
||
99 | abstract protected function executeCompressor(Compressor\Executable $compressor, Target $target, Result $result) : string; |
||
100 | } |
||
101 |