1 | <?php |
||
24 | class Dropbox implements Simulator |
||
25 | { |
||
26 | use Cleanable; |
||
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 \phpbu\App\Backup\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 | /** |
||
65 | * (non-PHPDoc) |
||
66 | * |
||
67 | * @see \phpbu\App\Backup\Sync::setup() |
||
68 | * @param array $config |
||
69 | * @throws \phpbu\App\Backup\Sync\Exception |
||
70 | * @throws \phpbu\App\Exception |
||
71 | */ |
||
72 | 8 | public function setup(array $config) |
|
88 | |||
89 | /** |
||
90 | * Make sure all mandatory keys are present in given config. |
||
91 | * |
||
92 | * @param array $config |
||
93 | * @param string[] $keys |
||
94 | * @throws Exception |
||
95 | */ |
||
96 | 8 | protected function validateConfig(array $config, array $keys) |
|
104 | |||
105 | /** |
||
106 | * (non-PHPDoc) |
||
107 | * |
||
108 | * @see \phpbu\App\Backup\Sync::sync() |
||
109 | * @param \phpbu\App\Backup\Target $target |
||
110 | * @param \phpbu\App\Result $result |
||
111 | * @throws \phpbu\App\Backup\Sync\Exception |
||
112 | */ |
||
113 | 3 | public function sync(Target $target, Result $result) |
|
131 | |||
132 | /** |
||
133 | * Simulate the sync execution. |
||
134 | * |
||
135 | * @param \phpbu\App\Backup\Target $target |
||
136 | * @param \phpbu\App\Result $result |
||
137 | */ |
||
138 | 2 | public function simulate(Target $target, Result $result) |
|
148 | |||
149 | /** |
||
150 | * Creates the Dropbox collector. |
||
151 | * |
||
152 | * @param \phpbu\App\Backup\Target $target |
||
153 | * @return \phpbu\App\Backup\Collector |
||
154 | */ |
||
155 | 1 | protected function createCollector(Target $target) : Collector |
|
162 | |||
163 | /** |
||
164 | * Create a dropbox api client. |
||
165 | * |
||
166 | * @return \Kunnu\Dropbox\Dropbox |
||
167 | */ |
||
168 | protected function createClient() : DropboxApi |
||
176 | } |
||
177 |