Completed
Push — master ( f19db6...33f856 )
by Aimeos
02:43
created
lib/custom/src/MW/Filesystem/Laravel.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param \Illuminate\Contracts\Filesystem\Filesystem $fs Laravel file system object
30 30
 	 * @param string $tempdir Directory for storing temporary files
31 31
 	 */
32
-	public function __construct( \Illuminate\Contracts\Filesystem\Filesystem $fs, $tempdir )
32
+	public function __construct(\Illuminate\Contracts\Filesystem\Filesystem $fs, $tempdir)
33 33
 	{
34 34
 		$this->fs = $fs;
35 35
 		$this->tempdir = $tempdir;
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	 * @return boolean True if directory, false if not
44 44
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
45 45
 	 */
46
-	public function isdir( $path )
46
+	public function isdir($path)
47 47
 	{
48
-		return in_array( basename( $path ), $this->fs->directories( dirname( $path ) ) );
48
+		return in_array(basename($path), $this->fs->directories(dirname($path)));
49 49
 	}
50 50
 
51 51
 
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
 	 * @return void
57 57
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
58 58
 	*/
59
-	public function mkdir( $path )
59
+	public function mkdir($path)
60 60
 	{
61 61
 		try {
62
-			$this->fs->makeDirectory( $path );
63
-		} catch( \Exception $e ) {
64
-			throw new Exception( $e->getMessage(), 0, $e );
62
+			$this->fs->makeDirectory($path);
63
+		} catch (\Exception $e) {
64
+			throw new Exception($e->getMessage(), 0, $e);
65 65
 		}
66 66
 	}
67 67
 
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 	 * @return void
74 74
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
75 75
 	*/
76
-	public function rmdir( $path )
76
+	public function rmdir($path)
77 77
 	{
78 78
 		try {
79
-			$this->fs->deleteDirectory( $path );
80
-		} catch( \Exception $e ) {
81
-			throw new Exception( $e->getMessage(), 0, $e );
79
+			$this->fs->deleteDirectory($path);
80
+		} catch (\Exception $e) {
81
+			throw new Exception($e->getMessage(), 0, $e);
82 82
 		}
83 83
 	}
84 84
 
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	 * @return \Iterator|array Iterator over the entries or array with entries
93 93
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
94 94
 	 */
95
-	public function scan( $path = null )
95
+	public function scan($path = null)
96 96
 	{
97 97
 		try {
98
-			return array_merge( $this->fs->directories( $path ), $this->fs->files( $path ) );
99
-		} catch( \Exception $e ) {
100
-			throw new Exception( $e->getMessage(), 0, $e );
98
+			return array_merge($this->fs->directories($path), $this->fs->files($path));
99
+		} catch (\Exception $e) {
100
+			throw new Exception($e->getMessage(), 0, $e);
101 101
 		}
102 102
 	}
103 103
 
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
 	 * @return integer Size in bytes
110 110
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
111 111
 	 */
112
-	public function size( $path )
112
+	public function size($path)
113 113
 	{
114 114
 		try {
115
-			return $this->fs->size( $path );
116
-		} catch( \Exception $e ) {
117
-			throw new Exception( $e->getMessage(), 0, $e );
115
+			return $this->fs->size($path);
116
+		} catch (\Exception $e) {
117
+			throw new Exception($e->getMessage(), 0, $e);
118 118
 		}
119 119
 	}
120 120
 
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 	 * @return integer Unix time stamp in seconds
127 127
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
128 128
 	 */
129
-	public function time( $path )
129
+	public function time($path)
130 130
 	{
131 131
 		try {
132
-			return $this->fs->lastModified( $path );
133
-		} catch( \Exception $e ) {
134
-			throw new Exception( $e->getMessage(), 0, $e );
132
+			return $this->fs->lastModified($path);
133
+		} catch (\Exception $e) {
134
+			throw new Exception($e->getMessage(), 0, $e);
135 135
 		}
136 136
 	}
137 137
 
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 	 * @return void
144 144
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
145 145
 	 */
146
-	public function rm( $path )
146
+	public function rm($path)
147 147
 	{
148 148
 		try {
149
-			$this->fs->delete( $path );
150
-		} catch( \Exception $e ) {
151
-			throw new Exception( $e->getMessage(), 0, $e );
149
+			$this->fs->delete($path);
150
+		} catch (\Exception $e) {
151
+			throw new Exception($e->getMessage(), 0, $e);
152 152
 		}
153 153
 	}
154 154
 
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	 * @param string $path Path to the file
160 160
 	 * @return boolean True if it exists, false if not
161 161
 	 */
162
-	public function has( $path )
162
+	public function has($path)
163 163
 	{
164
-		return $this->fs->exists( $path );
164
+		return $this->fs->exists($path);
165 165
 	}
166 166
 
167 167
 
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 	 * @return string File content
175 175
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
176 176
 	 */
177
-	public function read( $path )
177
+	public function read($path)
178 178
 	{
179 179
 		try {
180
-			return $this->fs->get( $path );
181
-		} catch( \Exception $e ) {
182
-			throw new Exception( $e->getMessage(), 0, $e );
180
+			return $this->fs->get($path);
181
+		} catch (\Exception $e) {
182
+			throw new Exception($e->getMessage(), 0, $e);
183 183
 		}
184 184
 	}
185 185
 
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 	 * @return string Path of the local file
192 192
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
193 193
 	 */
194
-	public function readf( $path )
194
+	public function readf($path)
195 195
 	{
196
-		if( ( $filename = tempnam( $this->tempdir, 'ai-' ) ) === false ) {
197
-			throw new Exception( sprintf( 'Unable to create file in "%1$s"', $this->tempdir ) );
196
+		if (($filename = tempnam($this->tempdir, 'ai-')) === false) {
197
+			throw new Exception(sprintf('Unable to create file in "%1$s"', $this->tempdir));
198 198
 		}
199 199
 
200
-		if( @file_put_contents( $filename, $this->fs->get( $path ) ) === false ) {
201
-			throw new Exception( sprintf( 'Couldn\'t write file "%1$s"', $filename ) );
200
+		if (@file_put_contents($filename, $this->fs->get($path)) === false) {
201
+			throw new Exception(sprintf('Couldn\'t write file "%1$s"', $filename));
202 202
 		}
203 203
 
204 204
 		return $filename;
@@ -214,24 +214,24 @@  discard block
 block discarded – undo
214 214
 	 * @return resource File stream descriptor
215 215
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
216 216
 	 */
217
-	public function reads( $path )
217
+	public function reads($path)
218 218
 	{
219 219
 		try {
220
-			$content = $this->fs->get( $path );
221
-		} catch( \Exception $e ) {
222
-			throw new Exception( $e->getMessage(), 0, $e );
220
+			$content = $this->fs->get($path);
221
+		} catch (\Exception $e) {
222
+			throw new Exception($e->getMessage(), 0, $e);
223 223
 		}
224 224
 
225
-		if( ( $stream = tmpfile() ) === false ) {
226
-			throw new Exception( 'Couldn\'t create temporary file' );
225
+		if (($stream = tmpfile()) === false) {
226
+			throw new Exception('Couldn\'t create temporary file');
227 227
 		}
228 228
 
229
-		if( fwrite( $stream, $content ) === false ) {
230
-			throw new Exception( 'Couldn\'t write to temporary file' );
229
+		if (fwrite($stream, $content) === false) {
230
+			throw new Exception('Couldn\'t write to temporary file');
231 231
 		}
232 232
 
233
-		if( rewind( $stream ) === false ) {
234
-			throw new Exception( 'Couldn\'t rewind temporary file' );
233
+		if (rewind($stream) === false) {
234
+			throw new Exception('Couldn\'t rewind temporary file');
235 235
 		}
236 236
 
237 237
 		return $stream;
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 	 * @return void
249 249
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
250 250
 	 */
251
-	public function write( $path, $content )
251
+	public function write($path, $content)
252 252
 	{
253 253
 		try {
254
-			$this->fs->put( $path, $content );
255
-		} catch( \Exception $e ) {
256
-			throw new Exception( $e->getMessage(), 0, $e );
254
+			$this->fs->put($path, $content);
255
+		} catch (\Exception $e) {
256
+			throw new Exception($e->getMessage(), 0, $e);
257 257
 		}
258 258
 	}
259 259
 
@@ -268,13 +268,13 @@  discard block
 block discarded – undo
268 268
 	 * @return void
269 269
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
270 270
 	 */
271
-	public function writef( $path, $local )
271
+	public function writef($path, $local)
272 272
 	{
273
-		if( ( $content = @file_get_contents( $local ) ) === false ) {
274
-			throw new Exception( sprintf( 'Couldn\'t read file "%1$s"', $local ) );
273
+		if (($content = @file_get_contents($local)) === false) {
274
+			throw new Exception(sprintf('Couldn\'t read file "%1$s"', $local));
275 275
 		}
276 276
 
277
-		$this->write( $path, $content );
277
+		$this->write($path, $content);
278 278
 	}
279 279
 
280 280
 
@@ -288,17 +288,17 @@  discard block
 block discarded – undo
288 288
 	 * @return void
289 289
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
290 290
 	 */
291
-	public function writes( $path, $stream )
291
+	public function writes($path, $stream)
292 292
 	{
293
-		if( ( $content = @fread( $stream, 0x7ffffffd ) ) === false ) {
293
+		if (($content = @fread($stream, 0x7ffffffd)) === false) {
294 294
 			$error = error_get_last();
295
-			throw new Exception( $error['message'] );
295
+			throw new Exception($error['message']);
296 296
 		}
297 297
 
298 298
 		try {
299
-			$this->fs->put( $path, $content );
300
-		} catch( \Exception $e ) {
301
-			throw new Exception( $e->getMessage(), 0, $e );
299
+			$this->fs->put($path, $content);
300
+		} catch (\Exception $e) {
301
+			throw new Exception($e->getMessage(), 0, $e);
302 302
 		}
303 303
 	}
304 304
 
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
 	 * @return void
312 312
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
313 313
 	 */
314
-	public function move( $from, $to )
314
+	public function move($from, $to)
315 315
 	{
316 316
 		try {
317
-			$this->fs->move( $from, $to );
318
-		} catch( \Exception $e ) {
319
-			throw new Exception( $e->getMessage(), 0, $e );
317
+			$this->fs->move($from, $to);
318
+		} catch (\Exception $e) {
319
+			throw new Exception($e->getMessage(), 0, $e);
320 320
 		}
321 321
 	}
322 322
 
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
 	 * @return void
330 330
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
331 331
 	 */
332
-	public function copy( $from, $to )
332
+	public function copy($from, $to)
333 333
 	{
334 334
 		try {
335
-			$this->fs->copy( $from, $to );
336
-		} catch( \Exception $e ) {
337
-			throw new Exception( $e->getMessage(), 0, $e );
335
+			$this->fs->copy($from, $to);
336
+		} catch (\Exception $e) {
337
+			throw new Exception($e->getMessage(), 0, $e);
338 338
 		}
339 339
 	}
340 340
 }
Please login to merge, or discard this patch.