1 | <?php |
||
7 | class GistBackupHandler |
||
8 | { |
||
9 | /** @var User $user */ |
||
10 | private $user; |
||
11 | |||
12 | /** @var GistFinder $gistFinder */ |
||
13 | private $gistFinder; |
||
14 | |||
15 | /** Max size in bytes of file that can be archived */ |
||
16 | const MAX_FILE_SIZE = 100000; |
||
17 | |||
18 | function __construct(GistFinder $gistFinder) |
||
23 | |||
24 | /** |
||
25 | * Backup gists. |
||
26 | * |
||
27 | * @return string|integer A path to gist archive or 0 if there are no files to backup. |
||
28 | */ |
||
29 | public function backup() |
||
43 | |||
44 | /** |
||
45 | * Get each gist file and save it in the user folder. |
||
46 | * |
||
47 | * Also checks the size of a file to determine if it should be ignored. |
||
48 | * |
||
49 | * @return array Paths to gist files. |
||
50 | */ |
||
51 | private function prepareFiles() |
||
73 | |||
74 | /** |
||
75 | * Create a zip archive and add files to it. |
||
76 | * |
||
77 | * @param array $files |
||
78 | * |
||
79 | * @return string Path to zip archive. |
||
80 | * |
||
81 | * @throws \Exception If the archive cannot be created. |
||
82 | */ |
||
83 | private function zipFiles(array $files) |
||
101 | |||
102 | /** |
||
103 | * Delete the previously prepared files. |
||
104 | */ |
||
105 | private function removeFiles() |
||
109 | } |
||
110 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.