Code Duplication    Length = 12-14 lines in 8 locations

lib/custom/src/MW/Filesystem/FlyBase.php 8 locations

@@ 125-138 (lines=14) @@
122
	 * @return integer Size in bytes
123
	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
124
	 */
125
	public function size( $path )
126
	{
127
		try {
128
			$size = $this->getProvider()->getSize( $path );
129
		} catch( \Exception $e ) {
130
			throw new Exception( $e->getMessage(), 0, $e );
131
		}
132
133
		if( $size === false ) {
134
			throw new Exception( $path );
135
		}
136
137
		return $size;
138
	}
139
140
141
	/**
@@ 148-161 (lines=14) @@
145
	 * @return integer Unix time stamp in seconds
146
	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
147
	 */
148
	public function time( $path )
149
	{
150
		try {
151
			$time = $this->getProvider()->getTimestamp( $path );
152
		} catch( \Exception $e ) {
153
			throw new Exception( $e->getMessage(), 0, $e );
154
		}
155
156
		if( $time === false ) {
157
			throw new Exception( $path );
158
		}
159
160
		return $time;
161
	}
162
163
164
	/**
@@ 202-215 (lines=14) @@
199
	 * @return string File content
200
	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
201
	 */
202
	public function read( $path )
203
	{
204
		try {
205
			$content = $this->getProvider()->read( $path );
206
		} catch( \Exception $e ) {
207
			throw new Exception( $e->getMessage(), 0, $e );
208
		}
209
210
		if( $content === false ) {
211
			throw new Exception( $path );
212
		}
213
214
		return $content;
215
	}
216
217
218
	/**
@@ 257-270 (lines=14) @@
254
	 * @return resource File stream descriptor
255
	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
256
	 */
257
	public function reads( $path )
258
	{
259
		try {
260
			$handle = $this->getProvider()->readStream( $path );
261
		} catch( \Exception $e ) {
262
			throw new Exception( $e->getMessage(), 0, $e );
263
		}
264
265
		if( $handle === false ) {
266
			throw new Exception( $path );
267
		}
268
269
		return $handle;
270
	}
271
272
273
	/**
@@ 283-294 (lines=12) @@
280
	 * @return void
281
	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
282
	 */
283
	public function write( $path, $content )
284
	{
285
		try {
286
			$result = $this->getProvider()->put( $path, $content );
287
		} catch( \Exception $e ) {
288
			throw new Exception( $e->getMessage(), 0, $e );
289
		}
290
291
		if( $result === false ) {
292
			throw new Exception( $path );
293
		}
294
	}
295
296
297
	/**
@@ 331-342 (lines=12) @@
328
	 * @return void
329
	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
330
	 */
331
	public function writes( $path, $stream )
332
	{
333
		try {
334
			$result = $this->getProvider()->putStream( $path, $stream );
335
		} catch( \Exception $e ) {
336
			throw new Exception( $e->getMessage(), 0, $e );
337
		}
338
339
		if( $result === false ) {
340
			throw new Exception( $path );
341
		}
342
	}
343
344
345
	/**
@@ 353-364 (lines=12) @@
350
	 * @return void
351
	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
352
	 */
353
	public function move( $from, $to )
354
	{
355
		try {
356
			$result = $this->getProvider()->rename( $from, $to );
357
		} catch( \Exception $e ) {
358
			throw new Exception( $e->getMessage(), 0, $e );
359
		}
360
361
		if( $result === false ) {
362
			throw new Exception( sprintf( 'Error moving "%1$s" to "%2$s"', $from, $to ) );
363
		}
364
	}
365
366
367
	/**
@@ 375-386 (lines=12) @@
372
	 * @return void
373
	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
374
	 */
375
	public function copy( $from, $to )
376
	{
377
		try {
378
			$result = $this->getProvider()->copy( $from, $to );
379
		} catch( \Exception $e ) {
380
			throw new Exception( $e->getMessage(), 0, $e );
381
		}
382
383
		if( $result === false ) {
384
			throw new Exception( sprintf( 'Error copying "%1$s" to "%2$s"', $from, $to ) );
385
		}
386
	}
387
388
389
	/**