|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace kalanis\kw_files\Access; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use kalanis\kw_files\Interfaces; |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class CompositeAdapter |
|
11
|
|
|
* @package kalanis\kw_files\Access |
|
12
|
|
|
* Pass work with files in storage in one class |
|
13
|
|
|
*/ |
|
14
|
|
|
class CompositeAdapter implements Interfaces\IProcessNodes, Interfaces\IProcessDirs, Interfaces\IProcessFiles |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var Interfaces\IProcessNodes */ |
|
17
|
|
|
protected $libNode = null; |
|
18
|
|
|
/** @var Interfaces\IProcessDirs */ |
|
19
|
|
|
protected $libDir = null; |
|
20
|
|
|
/** @var Interfaces\IProcessFiles */ |
|
21
|
|
|
protected $libFile = null; |
|
22
|
|
|
|
|
23
|
12 |
|
public function __construct(Interfaces\IProcessNodes $libNode, Interfaces\IProcessDirs $libDir, Interfaces\IProcessFiles $libFile) |
|
24
|
|
|
{ |
|
25
|
12 |
|
$this->libNode = $libNode; |
|
26
|
12 |
|
$this->libDir = $libDir; |
|
27
|
12 |
|
$this->libFile = $libFile; |
|
28
|
12 |
|
} |
|
29
|
|
|
|
|
30
|
6 |
|
public function createDir(array $entry, bool $deep = false): bool |
|
31
|
|
|
{ |
|
32
|
6 |
|
return $this->libDir->createDir($entry, $deep); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
1 |
|
public function readDir(array $entry, bool $loadRecursive = false, bool $wantSize = false): array |
|
36
|
|
|
{ |
|
37
|
1 |
|
return $this->libDir->readDir($entry, $loadRecursive, $wantSize); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
1 |
|
public function copyDir(array $source, array $dest): bool |
|
41
|
|
|
{ |
|
42
|
1 |
|
return $this->libDir->copyDir($source, $dest); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
1 |
|
public function moveDir(array $source, array $dest): bool |
|
46
|
|
|
{ |
|
47
|
1 |
|
return $this->libDir->moveDir($source, $dest); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
2 |
|
public function deleteDir(array $entry, bool $deep = false): bool |
|
51
|
|
|
{ |
|
52
|
2 |
|
return $this->libDir->deleteDir($entry, $deep); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
5 |
|
public function saveFile(array $entry, $content): bool |
|
56
|
|
|
{ |
|
57
|
5 |
|
return $this->libFile->saveFile($entry, $content); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
1 |
|
public function readFile(array $entry, ?int $offset = null, ?int $length = null) |
|
61
|
|
|
{ |
|
62
|
1 |
|
return $this->libFile->readFile($entry, $offset, $length); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
1 |
|
public function copyFile(array $source, array $dest): bool |
|
66
|
|
|
{ |
|
67
|
1 |
|
return $this->libFile->copyFile($source, $dest); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
1 |
|
public function moveFile(array $source, array $dest): bool |
|
71
|
|
|
{ |
|
72
|
1 |
|
return $this->libFile->moveFile($source, $dest); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
1 |
|
public function deleteFile(array $entry): bool |
|
76
|
|
|
{ |
|
77
|
1 |
|
return $this->libFile->deleteFile($entry); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
6 |
|
public function exists(array $entry): bool |
|
81
|
|
|
{ |
|
82
|
6 |
|
return $this->libNode->exists($entry); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
1 |
|
public function isReadable(array $entry): bool |
|
86
|
|
|
{ |
|
87
|
1 |
|
return $this->libNode->isReadable($entry); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
1 |
|
public function isWritable(array $entry): bool |
|
91
|
|
|
{ |
|
92
|
1 |
|
return $this->libNode->isWritable($entry); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
6 |
|
public function isDir(array $entry): bool |
|
96
|
|
|
{ |
|
97
|
6 |
|
return $this->libNode->isDir($entry); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
2 |
|
public function isFile(array $entry): bool |
|
101
|
|
|
{ |
|
102
|
2 |
|
return $this->libNode->isFile($entry); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
1 |
|
public function size(array $entry): ?int |
|
106
|
|
|
{ |
|
107
|
1 |
|
return $this->libNode->size($entry); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
1 |
|
public function created(array $entry): ?int |
|
111
|
|
|
{ |
|
112
|
1 |
|
return $this->libNode->created($entry); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
1 |
|
public function getNode(): Interfaces\IProcessNodes |
|
116
|
|
|
{ |
|
117
|
1 |
|
return $this->libNode; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
1 |
|
public function getDir(): Interfaces\IProcessDirs |
|
121
|
|
|
{ |
|
122
|
1 |
|
return $this->libDir; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
1 |
|
public function getFile(): Interfaces\IProcessFiles |
|
126
|
|
|
{ |
|
127
|
1 |
|
return $this->libFile; |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|