1 | <?php |
||
24 | class Dropbox implements Simulator |
||
25 | { |
||
26 | use Clearable; |
||
27 | |||
28 | /** |
||
29 | * API access token |
||
30 | * |
||
31 | * Goto https://www.dropbox.com/developers/apps |
||
32 | * create your app |
||
33 | * - Dropbox api app |
||
34 | * - files and datastore |
||
35 | * - yes |
||
36 | * - provide some app name "my-dropbox-app" |
||
37 | * - generate access token to authenticate connection to your dropbox |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $token; |
||
42 | |||
43 | /** |
||
44 | * Remote path |
||
45 | * |
||
46 | * @var Path |
||
47 | */ |
||
48 | protected $path; |
||
49 | |||
50 | /** |
||
51 | * Dropbox api client |
||
52 | * |
||
53 | * @var DropboxApi |
||
54 | */ |
||
55 | protected $client; |
||
56 | |||
57 | /** |
||
58 | * Unix timestamp of generating path from placeholder. |
||
59 | * |
||
60 | * @var int |
||
61 | */ |
||
62 | protected $time; |
||
63 | |||
64 | 5 | /** |
|
65 | * (non-PHPDoc) |
||
66 | 5 | * |
|
67 | * @see \phpbu\App\Backup\Sync::setup() |
||
68 | * @param array $config |
||
69 | 5 | * @throws \phpbu\App\Backup\Sync\Exception |
|
70 | 1 | * @throws \phpbu\App\Exception |
|
71 | */ |
||
72 | 4 | public function setup(array $config) |
|
87 | |||
88 | /** |
||
89 | * Make sure all mandatory keys are present in given config. |
||
90 | * |
||
91 | * @param array $config |
||
92 | * @param string[] $keys |
||
93 | * @throws Exception |
||
94 | */ |
||
95 | protected function validateConfig(array $config, array $keys) |
||
103 | |||
104 | /** |
||
105 | * (non-PHPDoc) |
||
106 | * |
||
107 | * @see \phpbu\App\Backup\Sync::sync() |
||
108 | * @param \phpbu\App\Backup\Target $target |
||
109 | * @param \phpbu\App\Result $result |
||
110 | * @throws \phpbu\App\Backup\Sync\Exception |
||
111 | */ |
||
112 | public function sync(Target $target, Result $result) |
||
130 | |||
131 | /** |
||
132 | * Simulate the sync execution. |
||
133 | * |
||
134 | * @param \phpbu\App\Backup\Target $target |
||
135 | * @param \phpbu\App\Result $result |
||
136 | */ |
||
137 | public function simulate(Target $target, Result $result) |
||
147 | |||
148 | /** |
||
149 | * Creates collector for Dropbox |
||
150 | * |
||
151 | * @param \phpbu\App\Backup\Target $target |
||
152 | * @return \phpbu\App\Backup\Collector |
||
153 | */ |
||
154 | protected function createCollector(Target $target): Collector |
||
158 | |||
159 | /** |
||
160 | * Create Dropbox api client |
||
161 | */ |
||
162 | protected function connect() |
||
167 | } |
||
168 |