Completed
Push — master ( 0dfc0e...6aff5c )
by Aimeos
04:11
created
lib/custom/tests/MW/Filesystem/FlyPhpcrTest.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@  discard block
 block discarded – undo
7 7
 {
8 8
 	protected function setUp()
9 9
 	{
10
-		if( !interface_exists( '\\League\\Flysystem\\FilesystemInterface' ) ) {
11
-			$this->markTestSkipped( 'Install Flysystem first' );
10
+		if (!interface_exists('\\League\\Flysystem\\FilesystemInterface')) {
11
+			$this->markTestSkipped('Install Flysystem first');
12 12
 		}
13 13
 	}
14 14
 
15 15
 
16 16
 	public function testGetProvider()
17 17
 	{
18
-		$object = new FlyPhpcr( [] );
19
-		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
18
+		$object = new FlyPhpcr([]);
19
+		$this->assertInstanceof('\Aimeos\MW\Filesystem\Iface', $object);
20 20
 
21
-		$this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' );
22
-		$object->has( 'test' );
21
+		$this->setExpectedException('\Aimeos\MW\Filesystem\Exception');
22
+		$object->has('test');
23 23
 	}
24 24
 
25 25
 
26 26
 	public function testGetProviderRoot()
27 27
 	{
28
-		if( !class_exists( '\League\Flysystem\Phpcr\PhpcrAdapter' ) ) {
29
-			$this->markTestSkipped( 'Install Flysystem PHPCR adapter' );
28
+		if (!class_exists('\League\Flysystem\Phpcr\PhpcrAdapter')) {
29
+			$this->markTestSkipped('Install Flysystem PHPCR adapter');
30 30
 		}
31 31
 
32 32
 		$config = array(
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 			'path' => '/tmp/fly_phpcr.db',
35 35
 			'root' => '/',
36 36
 		);
37
-		$object = new FlyPhpcr( $config );
38
-		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
37
+		$object = new FlyPhpcr($config);
38
+		$this->assertInstanceof('\Aimeos\MW\Filesystem\Iface', $object);
39 39
 
40
-		$this->setExpectedException( '\PHPCR\RepositoryException' );
41
-		$object->has( 'test' );
40
+		$this->setExpectedException('\PHPCR\RepositoryException');
41
+		$object->has('test');
42 42
 	}
43 43
 }
Please login to merge, or discard this patch.
lib/custom/tests/MW/Filesystem/FlyDropboxTest.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,19 +7,19 @@  discard block
 block discarded – undo
7 7
 {
8 8
 	protected function setUp()
9 9
 	{
10
-		if( !interface_exists( '\\League\\Flysystem\\FilesystemInterface' ) ) {
11
-			$this->markTestSkipped( 'Install Flysystem first' );
10
+		if (!interface_exists('\\League\\Flysystem\\FilesystemInterface')) {
11
+			$this->markTestSkipped('Install Flysystem first');
12 12
 		}
13 13
 	}
14 14
 
15 15
 
16 16
 	public function testGetProvider()
17 17
 	{
18
-		$object = new FlyDropbox( [] );
19
-		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
18
+		$object = new FlyDropbox([]);
19
+		$this->assertInstanceof('\Aimeos\MW\Filesystem\Iface', $object);
20 20
 
21
-		$this->setExpectedException( 'Aimeos\MW\Filesystem\Exception' );
22
-		$object->has( 'test' );
21
+		$this->setExpectedException('Aimeos\MW\Filesystem\Exception');
22
+		$object->has('test');
23 23
 	}
24 24
 
25 25
 
@@ -28,28 +28,28 @@  discard block
 block discarded – undo
28 28
 		$config = array(
29 29
 			'accesstoken' => 'test',
30 30
 		);
31
-		$object = new FlyDropbox( $config );
32
-		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
31
+		$object = new FlyDropbox($config);
32
+		$this->assertInstanceof('\Aimeos\MW\Filesystem\Iface', $object);
33 33
 
34
-		$this->setExpectedException( 'Aimeos\MW\Filesystem\Exception' );
35
-		$object->has( 'test' );
34
+		$this->setExpectedException('Aimeos\MW\Filesystem\Exception');
35
+		$object->has('test');
36 36
 	}
37 37
 
38 38
 
39 39
 	public function testGetProviderAccess()
40 40
 	{
41
-		if( !class_exists( '\League\Flysystem\Dropbox\DropboxAdapter' ) ) {
42
-			$this->markTestSkipped( 'Install Flysystem Dropbox adapter' );
41
+		if (!class_exists('\League\Flysystem\Dropbox\DropboxAdapter')) {
42
+			$this->markTestSkipped('Install Flysystem Dropbox adapter');
43 43
 		}
44 44
 
45 45
 		$config = array(
46 46
 			'accesstoken' => 'test',
47 47
 			'appsecret' => 'test',
48 48
 		);
49
-		$object = new FlyDropbox( $config );
50
-		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
49
+		$object = new FlyDropbox($config);
50
+		$this->assertInstanceof('\Aimeos\MW\Filesystem\Iface', $object);
51 51
 
52
-		$this->setExpectedException( 'Exception' );
53
-		$object->has( 'test' );
52
+		$this->setExpectedException('Exception');
53
+		$object->has('test');
54 54
 	}
55 55
 }
Please login to merge, or discard this patch.
lib/custom/src/MW/Filesystem/FlyBase.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param array $config Configuration options
30 30
 	 */
31
-	public function __construct( array $config )
31
+	public function __construct(array $config)
32 32
 	{
33 33
 		$this->config = $config;
34 34
 
35
-		if( !isset( $config['tempdir'] ) ) {
35
+		if (!isset($config['tempdir'])) {
36 36
 			$config['tempdir'] = sys_get_temp_dir();
37 37
 		}
38 38
 
39
-		if( !is_dir( $config['tempdir'] ) && mkdir( $config['tempdir'], 0755, true ) === false ) {
40
-			throw new Exception( sprintf( 'Directory "%1$s" could not be created', $config['tempdir'] ) );
39
+		if (!is_dir($config['tempdir']) && mkdir($config['tempdir'], 0755, true) === false) {
40
+			throw new Exception(sprintf('Directory "%1$s" could not be created', $config['tempdir']));
41 41
 		}
42 42
 
43 43
 		$ds = DIRECTORY_SEPARATOR;
44
-		$this->tempdir = realpath( str_replace( '/', $ds, rtrim( $config['tempdir'], '/' ) ) ) . $ds;
44
+		$this->tempdir = realpath(str_replace('/', $ds, rtrim($config['tempdir'], '/'))).$ds;
45 45
 	}
46 46
 
47 47
 
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	 * @return boolean True if directory, false if not
53 53
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
54 54
 	 */
55
-	public function isdir( $path )
55
+	public function isdir($path)
56 56
 	{
57
-		$result = $this->getProvider()->getMetadata( $path );
57
+		$result = $this->getProvider()->getMetadata($path);
58 58
 
59
-		if( $result['type'] === 'dir' ) {
59
+		if ($result['type'] === 'dir') {
60 60
 			return true;
61 61
 		}
62 62
 
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 	 * @return void
72 72
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
73 73
 	 */
74
-	public function mkdir( $path )
74
+	public function mkdir($path)
75 75
 	{
76
-		if( $this->getProvider()->createDir( $path ) === false ) {
77
-			throw new Exception( $path );
76
+		if ($this->getProvider()->createDir($path) === false) {
77
+			throw new Exception($path);
78 78
 		}
79 79
 	}
80 80
 
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 * @return void
87 87
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
88 88
 	 */
89
-	public function rmdir( $path )
89
+	public function rmdir($path)
90 90
 	{
91
-		if( $this->getProvider()->deleteDir( $path ) === false ) {
92
-			throw new Exception( $path );
91
+		if ($this->getProvider()->deleteDir($path) === false) {
92
+			throw new Exception($path);
93 93
 		}
94 94
 	}
95 95
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	 * @return \Iterator|array Iterator over the entries or array with entries
104 104
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
105 105
 	 */
106
-	public function scan( $path = null )
106
+	public function scan($path = null)
107 107
 	{
108 108
 		$list = [];
109 109
 
110
-		foreach( $this->getProvider()->listContents( $path ) as $entry ) {
110
+		foreach ($this->getProvider()->listContents($path) as $entry) {
111 111
 			$list[] = $entry['basename'];
112 112
 		}
113 113
 
@@ -122,16 +122,16 @@  discard block
 block discarded – undo
122 122
 	 * @return integer Size in bytes
123 123
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
124 124
 	 */
125
-	public function size( $path )
125
+	public function size($path)
126 126
 	{
127 127
 		try {
128
-			$size = $this->getProvider()->getSize( $path );
129
-		} catch( \Exception $e ) {
130
-			throw new Exception( $e->getMessage(), 0, $e );
128
+			$size = $this->getProvider()->getSize($path);
129
+		} catch (\Exception $e) {
130
+			throw new Exception($e->getMessage(), 0, $e);
131 131
 		}
132 132
 
133
-		if( $size === false ) {
134
-			throw new Exception( $path );
133
+		if ($size === false) {
134
+			throw new Exception($path);
135 135
 		}
136 136
 
137 137
 		return $size;
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
 	 * @return integer Unix time stamp in seconds
146 146
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
147 147
 	 */
148
-	public function time( $path )
148
+	public function time($path)
149 149
 	{
150 150
 		try {
151
-			$time = $this->getProvider()->getTimestamp( $path );
152
-		} catch( \Exception $e ) {
153
-			throw new Exception( $e->getMessage(), 0, $e );
151
+			$time = $this->getProvider()->getTimestamp($path);
152
+		} catch (\Exception $e) {
153
+			throw new Exception($e->getMessage(), 0, $e);
154 154
 		}
155 155
 
156
-		if( $time === false ) {
157
-			throw new Exception( $path );
156
+		if ($time === false) {
157
+			throw new Exception($path);
158 158
 		}
159 159
 
160 160
 		return $time;
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 	 * @return void
169 169
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
170 170
 	 */
171
-	public function rm( $path )
171
+	public function rm($path)
172 172
 	{
173 173
 		try {
174
-			$this->getProvider()->delete( $path );
175
-		} catch( \Exception $e ) {
176
-			throw new Exception( $e->getMessage(), 0, $e );
174
+			$this->getProvider()->delete($path);
175
+		} catch (\Exception $e) {
176
+			throw new Exception($e->getMessage(), 0, $e);
177 177
 		}
178 178
 	}
179 179
 
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
 	 * @param string $path Path to the file
185 185
 	 * @return boolean True if it exists, false if not
186 186
 	 */
187
-	public function has( $path )
187
+	public function has($path)
188 188
 	{
189
-		return $this->getProvider()->has( $path );
189
+		return $this->getProvider()->has($path);
190 190
 	}
191 191
 
192 192
 
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
 	 * @return string File content
200 200
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
201 201
 	 */
202
-	public function read( $path )
202
+	public function read($path)
203 203
 	{
204 204
 		try {
205
-			$content = $this->getProvider()->read( $path );
206
-		} catch( \Exception $e ) {
207
-			throw new Exception( $e->getMessage(), 0, $e );
205
+			$content = $this->getProvider()->read($path);
206
+		} catch (\Exception $e) {
207
+			throw new Exception($e->getMessage(), 0, $e);
208 208
 		}
209 209
 
210
-		if( $content === false ) {
211
-			throw new Exception( $path );
210
+		if ($content === false) {
211
+			throw new Exception($path);
212 212
 		}
213 213
 
214 214
 		return $content;
@@ -222,24 +222,24 @@  discard block
 block discarded – undo
222 222
 	 * @return string Path of the local file
223 223
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
224 224
 	 */
225
-	public function readf( $path )
225
+	public function readf($path)
226 226
 	{
227
-		if( ( $filename = tempnam( $this->tempdir, 'ai-' ) ) === false ) {
228
-			throw new Exception( sprintf( 'Unable to create file in "%1$s"', $this->tempdir ) );
227
+		if (($filename = tempnam($this->tempdir, 'ai-')) === false) {
228
+			throw new Exception(sprintf('Unable to create file in "%1$s"', $this->tempdir));
229 229
 		}
230 230
 
231
-		if( ( $handle = @fopen( $filename, 'w' ) ) === false ) {
232
-			throw new Exception( sprintf( 'Unable to open file "%1$s"', $filename ) );
231
+		if (($handle = @fopen($filename, 'w')) === false) {
232
+			throw new Exception(sprintf('Unable to open file "%1$s"', $filename));
233 233
 		}
234 234
 
235
-		$stream = $this->reads( $path );
235
+		$stream = $this->reads($path);
236 236
 
237
-		if( @stream_copy_to_stream( $stream, $handle ) == false ) {
238
-			throw new Exception( sprintf( 'Couldn\'t copy stream for "%1$s"', $path ) );
237
+		if (@stream_copy_to_stream($stream, $handle) == false) {
238
+			throw new Exception(sprintf('Couldn\'t copy stream for "%1$s"', $path));
239 239
 		}
240 240
 
241
-		fclose( $stream );
242
-		fclose( $handle );
241
+		fclose($stream);
242
+		fclose($handle);
243 243
 
244 244
 		return $filename;
245 245
 	}
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
 	 * @return resource File stream descriptor
255 255
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
256 256
 	 */
257
-	public function reads( $path )
257
+	public function reads($path)
258 258
 	{
259 259
 		try {
260
-			$handle = $this->getProvider()->readStream( $path );
261
-		} catch( \Exception $e ) {
262
-			throw new Exception( $e->getMessage(), 0, $e );
260
+			$handle = $this->getProvider()->readStream($path);
261
+		} catch (\Exception $e) {
262
+			throw new Exception($e->getMessage(), 0, $e);
263 263
 		}
264 264
 
265
-		if( $handle === false ) {
266
-			throw new Exception( $path );
265
+		if ($handle === false) {
266
+			throw new Exception($path);
267 267
 		}
268 268
 
269 269
 		return $handle;
@@ -280,16 +280,16 @@  discard block
 block discarded – undo
280 280
 	 * @return void
281 281
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
282 282
 	 */
283
-	public function write( $path, $content )
283
+	public function write($path, $content)
284 284
 	{
285 285
 		try {
286
-			$result = $this->getProvider()->put( $path, $content );
287
-		} catch( \Exception $e ) {
288
-			throw new Exception( $e->getMessage(), 0, $e );
286
+			$result = $this->getProvider()->put($path, $content);
287
+		} catch (\Exception $e) {
288
+			throw new Exception($e->getMessage(), 0, $e);
289 289
 		}
290 290
 
291
-		if( $result === false ) {
292
-			throw new Exception( $path );
291
+		if ($result === false) {
292
+			throw new Exception($path);
293 293
 		}
294 294
 	}
295 295
 
@@ -304,16 +304,16 @@  discard block
 block discarded – undo
304 304
 	 * @return void
305 305
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
306 306
 	 */
307
-	public function writef( $path, $local )
307
+	public function writef($path, $local)
308 308
 	{
309
-		if( ( $handle = @fopen( $local, 'r' ) ) === false ) {
310
-			throw new Exception( sprintf( 'Unable to open file "%1$s"', $local ) );
309
+		if (($handle = @fopen($local, 'r')) === false) {
310
+			throw new Exception(sprintf('Unable to open file "%1$s"', $local));
311 311
 		}
312 312
 
313
-		$this->writes( $path, $handle );
313
+		$this->writes($path, $handle);
314 314
 
315
-		if( is_resource( $handle ) ) {
316
-			fclose( $handle );
315
+		if (is_resource($handle)) {
316
+			fclose($handle);
317 317
 		}
318 318
 	}
319 319
 
@@ -328,16 +328,16 @@  discard block
 block discarded – undo
328 328
 	 * @return void
329 329
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
330 330
 	 */
331
-	public function writes( $path, $stream )
331
+	public function writes($path, $stream)
332 332
 	{
333 333
 		try {
334
-			$result = $this->getProvider()->putStream( $path, $stream );
335
-		} catch( \Exception $e ) {
336
-			throw new Exception( $e->getMessage(), 0, $e );
334
+			$result = $this->getProvider()->putStream($path, $stream);
335
+		} catch (\Exception $e) {
336
+			throw new Exception($e->getMessage(), 0, $e);
337 337
 		}
338 338
 
339
-		if( $result === false ) {
340
-			throw new Exception( $path );
339
+		if ($result === false) {
340
+			throw new Exception($path);
341 341
 		}
342 342
 	}
343 343
 
@@ -350,16 +350,16 @@  discard block
 block discarded – undo
350 350
 	 * @return void
351 351
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
352 352
 	 */
353
-	public function move( $from, $to )
353
+	public function move($from, $to)
354 354
 	{
355 355
 		try {
356
-			$result = $this->getProvider()->rename( $from, $to );
357
-		} catch( \Exception $e ) {
358
-			throw new Exception( $e->getMessage(), 0, $e );
356
+			$result = $this->getProvider()->rename($from, $to);
357
+		} catch (\Exception $e) {
358
+			throw new Exception($e->getMessage(), 0, $e);
359 359
 		}
360 360
 
361
-		if( $result === false ) {
362
-			throw new Exception( sprintf( 'Error moving "%1$s" to "%2$s"', $from, $to ) );
361
+		if ($result === false) {
362
+			throw new Exception(sprintf('Error moving "%1$s" to "%2$s"', $from, $to));
363 363
 		}
364 364
 	}
365 365
 
@@ -372,16 +372,16 @@  discard block
 block discarded – undo
372 372
 	 * @return void
373 373
 	 * @throws \Aimeos\MW\Filesystem\Exception If an error occurs
374 374
 	 */
375
-	public function copy( $from, $to )
375
+	public function copy($from, $to)
376 376
 	{
377 377
 		try {
378
-			$result = $this->getProvider()->copy( $from, $to );
379
-		} catch( \Exception $e ) {
380
-			throw new Exception( $e->getMessage(), 0, $e );
378
+			$result = $this->getProvider()->copy($from, $to);
379
+		} catch (\Exception $e) {
380
+			throw new Exception($e->getMessage(), 0, $e);
381 381
 		}
382 382
 
383
-		if( $result === false ) {
384
-			throw new Exception( sprintf( 'Error copying "%1$s" to "%2$s"', $from, $to ) );
383
+		if ($result === false) {
384
+			throw new Exception(sprintf('Error copying "%1$s" to "%2$s"', $from, $to));
385 385
 		}
386 386
 	}
387 387
 
Please login to merge, or discard this patch.