1 | <?php |
||
22 | class Source extends Abstraction |
||
23 | { |
||
24 | /** |
||
25 | * Executes the backup and compression. |
||
26 | * |
||
27 | * @param \phpbu\App\Backup\Source $source |
||
28 | * @param \phpbu\App\Backup\Target $target |
||
29 | * @param \phpbu\App\Result $result |
||
30 | * @throws \phpbu\App\Exception |
||
31 | */ |
||
32 | 4 | public function run(SourceExe $source, Target $target, Result $result) |
|
36 | |||
37 | /** |
||
38 | * Executes the backup and compression. |
||
39 | * |
||
40 | * @param \phpbu\App\Backup\Source $source |
||
41 | * @param \phpbu\App\Backup\Target $target |
||
42 | * @param \phpbu\App\Result $result |
||
43 | * @throws \phpbu\App\Exception |
||
44 | */ |
||
45 | 2 | protected function backup(SourceExe $source, Target $target, Result $result) |
|
50 | |||
51 | /** |
||
52 | * Simulates the backup. |
||
53 | * |
||
54 | * @param \phpbu\App\Backup\Source $source |
||
55 | * @param \phpbu\App\Backup\Target $target |
||
56 | * @param \phpbu\App\Result $result |
||
57 | * @throws \phpbu\App\Exception |
||
58 | */ |
||
59 | 2 | protected function simulate(SourceExe $source, Target $target, Result $result) |
|
66 | |||
67 | /** |
||
68 | * Compress the backup if the source did not handle the compression. |
||
69 | * |
||
70 | * @param \phpbu\App\Backup\Source\Status $status |
||
71 | * @param \phpbu\App\Backup\Target $target |
||
72 | * @param \phpbu\App\Result $result |
||
73 | * @throws \phpbu\App\Exception |
||
74 | */ |
||
75 | 4 | protected function compress(Status $status, Target $target, Result $result) |
|
83 | |||
84 | /** |
||
85 | * Handle directory compression for sources which can't handle compression by them self. |
||
86 | * |
||
87 | * @param \phpbu\App\Backup\Target $target |
||
88 | * @param \phpbu\App\Result $result |
||
89 | * @param \phpbu\App\Backup\Source\Status $status |
||
90 | * @throws \phpbu\App\Exception |
||
91 | */ |
||
92 | 3 | private function handleCompression(Target $target, Result $result, Status $status) |
|
101 | |||
102 | /** |
||
103 | * Compresses the target if the target is a directory. |
||
104 | * |
||
105 | * @param \phpbu\App\Backup\Target $target |
||
106 | * @param \phpbu\App\Result $result |
||
107 | * @param string $dataToCompress |
||
108 | * @throws \phpbu\App\Exception |
||
109 | */ |
||
110 | 1 | private function compressDirectory(Target $target, Result $result, $dataToCompress) |
|
122 | |||
123 | /** |
||
124 | * Compresses the target if the target is a single file. |
||
125 | * |
||
126 | * @param \phpbu\App\Backup\Target $target |
||
127 | * @param \phpbu\App\Result $result |
||
128 | * @param string $dataToCompress |
||
129 | * @throws \phpbu\App\Exception |
||
130 | */ |
||
131 | 3 | private function compressFile(Target $target, Result $result, $dataToCompress) |
|
136 | |||
137 | /** |
||
138 | * Execute the compressor. |
||
139 | * Returns the path to the created archive file. |
||
140 | * |
||
141 | * @param \phpbu\App\Backup\Compressor\Executable $compressor |
||
142 | * @param \phpbu\App\Backup\Target $target |
||
143 | * @param \phpbu\App\Result $result |
||
144 | * @return string |
||
145 | */ |
||
146 | 3 | private function executeCompressor(Compressor\Executable $compressor, Target $target, Result $result) : string |
|
156 | } |
||
157 |