Filesystem::getSize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 1
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Mosaic\Filesystem\Adapters\Flysystem;
4
5
use League\Flysystem\MountManager;
6
use Mosaic\Filesystem\Filesystem as FilesystemInterface;
7
8
class Filesystem implements FilesystemInterface
9
{
10
    /**
11
     * @var MountManager
12
     */
13
    private $manager;
14
15
    /**
16
     * Filesystem constructor.
17
     * @param MountManager $manager
18
     */
19 22
    public function __construct(MountManager $manager)
20
    {
21 22
        $this->manager = $manager;
22 22
    }
23
24
    /**
25
     * Check whether a file exists.
26
     *
27
     * @param  string $path
28
     * @return bool
29
     */
30 1
    public function has($path)
31
    {
32 1
        return $this->manager->has($path);
33
    }
34
35
    /**
36
     * Read a file.
37
     *
38
     * @param  string       $path The path to the file.
39
     * @return string|false The file contents or false on failure.
40
     */
41 1
    public function read($path)
42
    {
43 1
        return $this->manager->read($path);
44
    }
45
46
    /**
47
     * Retrieves a read-stream for a path.
48
     *
49
     * @param  string         $path The path to the file.
50
     * @return resource|false The path resource or false on failure.
51
     */
52 1
    public function readStream($path)
53
    {
54 1
        return $this->manager->readStream($path);
55
    }
56
57
    /**
58
     * List contents of a directory.
59
     *
60
     * @param  string $directory The directory to list.
61
     * @param  bool   $recursive Whether to list recursively.
62
     * @return array  A list of file metadata.
63
     */
64 1
    public function listContents($directory = '', $recursive = false)
65
    {
66 1
        return $this->manager->listContents($directory, $recursive);
67
    }
68
69
    /**
70
     * Get a file's metadata.
71
     *
72
     * @param  string      $path The path to the file.
73
     * @return array|false The file metadata or false on failure.
74
     */
75 1
    public function getMetadata($path)
76
    {
77 1
        return $this->manager->getMetadata($path);
78
    }
79
80
    /**
81
     * Get a file's size.
82
     *
83
     * @param  string    $path The path to the file.
84
     * @return int|false The file size or false on failure.
85
     */
86 1
    public function getSize($path)
87
    {
88 1
        return $this->manager->getSize($path);
89
    }
90
91
    /**
92
     * Get a file's mime-type.
93
     *
94
     * @param  string       $path The path to the file.
95
     * @return string|false The file mime-type or false on failure.
96
     */
97 1
    public function getMimetype($path)
98
    {
99 1
        return $this->manager->getMimetype($path);
100
    }
101
102
    /**
103
     * Get a file's timestamp.
104
     *
105
     * @param  string       $path The path to the file.
106
     * @return string|false The timestamp or false on failure.
107
     */
108 1
    public function getTimestamp($path)
109
    {
110 1
        return $this->manager->getTimestamp($path);
111
    }
112
113
    /**
114
     * Get a file's visibility.
115
     *
116
     * @param  string       $path The path to the file.
117
     * @return string|false The visibility (public|private) or false on failure.
118
     */
119 1
    public function getVisibility($path)
120
    {
121 1
        return $this->manager->getVisibility($path);
122
    }
123
124
    /**
125
     * Write a new file.
126
     *
127
     * @param  string $path     The path of the new file.
128
     * @param  string $contents The file contents.
129
     * @param  array  $config   An optional configuration array.
130
     * @return bool   True on success, false on failure.
131
     */
132 1
    public function write($path, $contents, array $config = [])
133
    {
134 1
        return $this->manager->write($path, $contents, $config);
135
    }
136
137
    /**
138
     * Write a new file using a stream.
139
     *
140
     * @param  string   $path     The path of the new file.
141
     * @param  resource $resource The file handle.
142
     * @param  array    $config   An optional configuration array.
143
     * @return bool     True on success, false on failure.
144
     */
145 1
    public function writeStream($path, $resource, array $config = [])
146
    {
147 1
        return $this->manager->writeStream($path, $resource, $config);
148
    }
149
150
    /**
151
     * Update an existing file.
152
     *
153
     * @param  string $path     The path of the existing file.
154
     * @param  string $contents The file contents.
155
     * @param  array  $config   An optional configuration array.
156
     * @return bool   True on success, false on failure.
157
     */
158 1
    public function update($path, $contents, array $config = [])
159
    {
160 1
        return $this->manager->update($path, $contents, $config);
161
    }
162
163
    /**
164
     * Update an existing file using a stream.
165
     *
166
     * @param  string   $path     The path of the existing file.
167
     * @param  resource $resource The file handle.
168
     * @param  array    $config   An optional configuration array.
169
     * @return bool     True on success, false on failure.
170
     */
171 1
    public function updateStream($path, $resource, array $config = [])
172
    {
173 1
        return $this->manager->updateStream($path, $resource, $config);
174
    }
175
176
    /**
177
     * Rename a file.
178
     *
179
     * @param  string $path    Path to the existing file.
180
     * @param  string $newpath The new path of the file.
181
     * @return bool   True on success, false on failure.
182
     */
183 1
    public function rename($path, $newpath)
184
    {
185 1
        return $this->manager->rename($path, $newpath);
186
    }
187
188
    /**
189
     * Copy a file.
190
     *
191
     * @param  string $path    Path to the existing file.
192
     * @param  string $newpath The new path of the file.
193
     * @return bool   True on success, false on failure.
194
     */
195 1
    public function copy($path, $newpath)
196
    {
197 1
        return $this->manager->copy($path, $newpath);
198
    }
199
200
    /**
201
     * Delete a file.
202
     *
203
     * @param  string $path
204
     * @return bool   True on success, false on failure.
205
     */
206 1
    public function delete($path)
207
    {
208 1
        return $this->manager->delete($path);
209
    }
210
211
    /**
212
     * Delete a directory.
213
     *
214
     * @param  string $dirname
215
     * @return bool   True on success, false on failure.
216
     */
217 1
    public function deleteDir($dirname)
218
    {
219 1
        return $this->manager->deleteDir($dirname);
220
    }
221
222
    /**
223
     * Create a directory.
224
     *
225
     * @param  string $dirname The name of the new directory.
226
     * @param  array  $config  An optional configuration array.
227
     * @return bool   True on success, false on failure.
228
     */
229 1
    public function createDir($dirname, array $config = [])
230
    {
231 1
        return $this->manager->createDir($dirname, $config);
232
    }
233
234
    /**
235
     * Set the visibility for a file.
236
     *
237
     * @param  string $path       The path to the file.
238
     * @param  string $visibility One of 'public' or 'private'.
239
     * @return bool   True on success, false on failure.
240
     */
241 1
    public function setVisibility($path, $visibility)
242
    {
243 1
        return $this->manager->setVisibility($path, $visibility);
244
    }
245
246
    /**
247
     * Create a file or update if exists.
248
     *
249
     * @param  string $path     The path to the file.
250
     * @param  string $contents The file contents.
251
     * @param  array  $config   An optional configuration array.
252
     * @return bool   True on success, false on failure.
253
     */
254 1
    public function put($path, $contents, array $config = [])
255
    {
256 1
        return $this->manager->put($path, $contents, $config);
257
    }
258
259
    /**
260
     * Create a file or update if exists.
261
     *
262
     * @param  string   $path     The path to the file.
263
     * @param  resource $resource The file handle.
264
     * @param  array    $config   An optional configuration array.
265
     * @return bool     True on success, false on failure.
266
     */
267 1
    public function putStream($path, $resource, array $config = [])
268
    {
269 1
        return $this->manager->putStream($path, $resource, $config);
270
    }
271
272
    /**
273
     * Read and delete a file.
274
     *
275
     * @param  string       $path The path to the file.
276
     * @return string|false The file contents, or false on failure.
277
     */
278 1
    public function readAndDelete($path)
279
    {
280 1
        return $this->manager->readAndDelete($path);
281
    }
282
}
283