Passed
Push — master ( 826624...dee1d8 )
by Morris
16:59 queued 04:01
created

LazyFolder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * @copyright Copyright (c) 2020 Robin Appelman <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OC\Files\Node;
25
26
/**
27
 * Class LazyFolder
28
 *
29
 * This is a lazy wrapper around a folder. So only
30
 * once it is needed this will get initialized.
31
 *
32
 * @package OC\Files\Node
33
 */
34
class LazyFolder implements \OCP\Files\Folder {
35
	/** @var \Closure */
36
	private $folderClosure;
37
38
	/** @var LazyFolder | null */
39
	private $folder = null;
40
41
	/**
42
	 * LazyFolder constructor.
43
	 *
44
	 * @param \Closure $folderClosure
45
	 */
46
	public function __construct(\Closure $folderClosure) {
47
		$this->folderClosure = $folderClosure;
48
	}
49
50
	/**
51
	 * Magic method to first get the real rootFolder and then
52
	 * call $method with $args on it
53
	 *
54
	 * @param $method
55
	 * @param $args
56
	 * @return mixed
57
	 */
58
	public function __call($method, $args) {
59
		if ($this->folder === null) {
60
			$this->folder = call_user_func($this->folderClosure);
61
		}
62
63
		return call_user_func_array([$this->folder, $method], $args);
64
	}
65
66
	/**
67
	 * @inheritDoc
68
	 */
69
	public function getUser() {
70
		return $this->__call(__FUNCTION__, func_get_args());
71
	}
72
73
	/**
74
	 * @inheritDoc
75
	 */
76
	public function listen($scope, $method, callable $callback) {
77
		$this->__call(__FUNCTION__, func_get_args());
78
	}
79
80
	/**
81
	 * @inheritDoc
82
	 */
83
	public function removeListener($scope = null, $method = null, callable $callback = null) {
84
		$this->__call(__FUNCTION__, func_get_args());
85
	}
86
87
	/**
88
	 * @inheritDoc
89
	 */
90
	public function emit($scope, $method, $arguments = []) {
91
		$this->__call(__FUNCTION__, func_get_args());
92
	}
93
94
	/**
95
	 * @inheritDoc
96
	 */
97
	public function mount($storage, $mountPoint, $arguments = []) {
98
		$this->__call(__FUNCTION__, func_get_args());
99
	}
100
101
	/**
102
	 * @inheritDoc
103
	 */
104
	public function getMount($mountPoint) {
105
		return $this->__call(__FUNCTION__, func_get_args());
106
	}
107
108
	/**
109
	 * @inheritDoc
110
	 */
111
	public function getMountsIn($mountPoint) {
112
		return $this->__call(__FUNCTION__, func_get_args());
113
	}
114
115
	/**
116
	 * @inheritDoc
117
	 */
118
	public function getMountByStorageId($storageId) {
119
		return $this->__call(__FUNCTION__, func_get_args());
120
	}
121
122
	/**
123
	 * @inheritDoc
124
	 */
125
	public function getMountByNumericStorageId($numericId) {
126
		return $this->__call(__FUNCTION__, func_get_args());
127
	}
128
129
	/**
130
	 * @inheritDoc
131
	 */
132
	public function unMount($mount) {
133
		$this->__call(__FUNCTION__, func_get_args());
134
	}
135
136
	/**
137
	 * @inheritDoc
138
	 */
139
	public function get($path) {
140
		return $this->__call(__FUNCTION__, func_get_args());
141
	}
142
143
	/**
144
	 * @inheritDoc
145
	 */
146
	public function rename($targetPath) {
147
		return $this->__call(__FUNCTION__, func_get_args());
148
	}
149
150
	/**
151
	 * @inheritDoc
152
	 */
153
	public function delete() {
154
		return $this->__call(__FUNCTION__, func_get_args());
155
	}
156
157
	/**
158
	 * @inheritDoc
159
	 */
160
	public function copy($targetPath) {
161
		return $this->__call(__FUNCTION__, func_get_args());
162
	}
163
164
	/**
165
	 * @inheritDoc
166
	 */
167
	public function touch($mtime = null) {
168
		$this->__call(__FUNCTION__, func_get_args());
169
	}
170
171
	/**
172
	 * @inheritDoc
173
	 */
174
	public function getStorage() {
175
		return $this->__call(__FUNCTION__, func_get_args());
176
	}
177
178
	/**
179
	 * @inheritDoc
180
	 */
181
	public function getPath() {
182
		return $this->__call(__FUNCTION__, func_get_args());
183
	}
184
185
	/**
186
	 * @inheritDoc
187
	 */
188
	public function getInternalPath() {
189
		return $this->__call(__FUNCTION__, func_get_args());
190
	}
191
192
	/**
193
	 * @inheritDoc
194
	 */
195
	public function getId() {
196
		return $this->__call(__FUNCTION__, func_get_args());
197
	}
198
199
	/**
200
	 * @inheritDoc
201
	 */
202
	public function stat() {
203
		return $this->__call(__FUNCTION__, func_get_args());
204
	}
205
206
	/**
207
	 * @inheritDoc
208
	 */
209
	public function getMTime() {
210
		return $this->__call(__FUNCTION__, func_get_args());
211
	}
212
213
	/**
214
	 * @inheritDoc
215
	 */
216
	public function getSize($includeMounts = true) {
217
		return $this->__call(__FUNCTION__, func_get_args());
218
	}
219
220
	/**
221
	 * @inheritDoc
222
	 */
223
	public function getEtag() {
224
		return $this->__call(__FUNCTION__, func_get_args());
225
	}
226
227
	/**
228
	 * @inheritDoc
229
	 */
230
	public function getPermissions() {
231
		return $this->__call(__FUNCTION__, func_get_args());
232
	}
233
234
	/**
235
	 * @inheritDoc
236
	 */
237
	public function isReadable() {
238
		return $this->__call(__FUNCTION__, func_get_args());
239
	}
240
241
	/**
242
	 * @inheritDoc
243
	 */
244
	public function isUpdateable() {
245
		return $this->__call(__FUNCTION__, func_get_args());
246
	}
247
248
	/**
249
	 * @inheritDoc
250
	 */
251
	public function isDeletable() {
252
		return $this->__call(__FUNCTION__, func_get_args());
253
	}
254
255
	/**
256
	 * @inheritDoc
257
	 */
258
	public function isShareable() {
259
		return $this->__call(__FUNCTION__, func_get_args());
260
	}
261
262
	/**
263
	 * @inheritDoc
264
	 */
265
	public function getParent() {
266
		return $this->__call(__FUNCTION__, func_get_args());
267
	}
268
269
	/**
270
	 * @inheritDoc
271
	 */
272
	public function getName() {
273
		return $this->__call(__FUNCTION__, func_get_args());
274
	}
275
276
	/**
277
	 * @inheritDoc
278
	 */
279
	public function getUserFolder($userId) {
280
		return $this->__call(__FUNCTION__, func_get_args());
281
	}
282
283
	/**
284
	 * @inheritDoc
285
	 */
286
	public function getMimetype() {
287
		return $this->__call(__FUNCTION__, func_get_args());
288
	}
289
290
	/**
291
	 * @inheritDoc
292
	 */
293
	public function getMimePart() {
294
		return $this->__call(__FUNCTION__, func_get_args());
295
	}
296
297
	/**
298
	 * @inheritDoc
299
	 */
300
	public function isEncrypted() {
301
		return $this->__call(__FUNCTION__, func_get_args());
302
	}
303
304
	/**
305
	 * @inheritDoc
306
	 */
307
	public function getType() {
308
		return $this->__call(__FUNCTION__, func_get_args());
309
	}
310
311
	/**
312
	 * @inheritDoc
313
	 */
314
	public function isShared() {
315
		return $this->__call(__FUNCTION__, func_get_args());
316
	}
317
318
	/**
319
	 * @inheritDoc
320
	 */
321
	public function isMounted() {
322
		return $this->__call(__FUNCTION__, func_get_args());
323
	}
324
325
	/**
326
	 * @inheritDoc
327
	 */
328
	public function getMountPoint() {
329
		return $this->__call(__FUNCTION__, func_get_args());
330
	}
331
332
	/**
333
	 * @inheritDoc
334
	 */
335
	public function getOwner() {
336
		return $this->__call(__FUNCTION__, func_get_args());
337
	}
338
339
	/**
340
	 * @inheritDoc
341
	 */
342
	public function getChecksum() {
343
		return $this->__call(__FUNCTION__, func_get_args());
344
	}
345
346
	public function getExtension(): string {
347
		return $this->__call(__FUNCTION__, func_get_args());
348
	}
349
350
	/**
351
	 * @inheritDoc
352
	 */
353
	public function getFullPath($path) {
354
		return $this->__call(__FUNCTION__, func_get_args());
355
	}
356
357
	/**
358
	 * @inheritDoc
359
	 */
360
	public function getRelativePath($path) {
361
		return $this->__call(__FUNCTION__, func_get_args());
362
	}
363
364
	/**
365
	 * @inheritDoc
366
	 */
367
	public function isSubNode($node) {
368
		return $this->__call(__FUNCTION__, func_get_args());
369
	}
370
371
	/**
372
	 * @inheritDoc
373
	 */
374
	public function getDirectoryListing() {
375
		return $this->__call(__FUNCTION__, func_get_args());
376
	}
377
378
	/**
379
	 * @inheritDoc
380
	 */
381
	public function nodeExists($path) {
382
		return $this->__call(__FUNCTION__, func_get_args());
383
	}
384
385
	/**
386
	 * @inheritDoc
387
	 */
388
	public function newFolder($path) {
389
		return $this->__call(__FUNCTION__, func_get_args());
390
	}
391
392
	/**
393
	 * @inheritDoc
394
	 */
395
	public function newFile($path, $content = null) {
396
		return $this->__call(__FUNCTION__, func_get_args());
397
	}
398
399
	/**
400
	 * @inheritDoc
401
	 */
402
	public function search($query) {
403
		return $this->__call(__FUNCTION__, func_get_args());
404
	}
405
406
	/**
407
	 * @inheritDoc
408
	 */
409
	public function searchByMime($mimetype) {
410
		return $this->__call(__FUNCTION__, func_get_args());
411
	}
412
413
	/**
414
	 * @inheritDoc
415
	 */
416
	public function searchByTag($tag, $userId) {
417
		return $this->__call(__FUNCTION__, func_get_args());
418
	}
419
420
	/**
421
	 * @inheritDoc
422
	 */
423
	public function getById($id) {
424
		return $this->__call(__FUNCTION__, func_get_args());
425
	}
426
427
	/**
428
	 * @inheritDoc
429
	 */
430
	public function getFreeSpace() {
431
		return $this->__call(__FUNCTION__, func_get_args());
432
	}
433
434
	/**
435
	 * @inheritDoc
436
	 */
437
	public function isCreatable() {
438
		return $this->__call(__FUNCTION__, func_get_args());
439
	}
440
441
	/**
442
	 * @inheritDoc
443
	 */
444
	public function getNonExistingName($name) {
445
		return $this->__call(__FUNCTION__, func_get_args());
446
	}
447
448
	/**
449
	 * @inheritDoc
450
	 */
451
	public function move($targetPath) {
452
		return $this->__call(__FUNCTION__, func_get_args());
453
	}
454
455
	/**
456
	 * @inheritDoc
457
	 */
458
	public function lock($type) {
459
		return $this->__call(__FUNCTION__, func_get_args());
460
	}
461
462
	/**
463
	 * @inheritDoc
464
	 */
465
	public function changeLock($targetType) {
466
		return $this->__call(__FUNCTION__, func_get_args());
467
	}
468
469
	/**
470
	 * @inheritDoc
471
	 */
472
	public function unlock($type) {
473
		return $this->__call(__FUNCTION__, func_get_args());
474
	}
475
476
	/**
477
	 * @inheritDoc
478
	 */
479
	public function getRecent($limit, $offset = 0) {
480
		return $this->__call(__FUNCTION__, func_get_args());
481
	}
482
483
	/**
484
	 * @inheritDoc
485
	 */
486
	public function getCreationTime(): int {
487
		return $this->__call(__FUNCTION__, func_get_args());
488
	}
489
490
	/**
491
	 * @inheritDoc
492
	 */
493
	public function getUploadTime(): int {
494
		return $this->__call(__FUNCTION__, func_get_args());
495
	}
496
}
497