Passed
Push — releases ( 51c2cc...e1d10c )
by steve
39:06 queued 13:38
created
neon/firefly/services/driveManager/Drive.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
 		foreach ($paths as $path) {
237 237
 			try {
238
-				if (! $this->_flysystem->delete($path)) {
238
+				if (!$this->_flysystem->delete($path)) {
239 239
 					$success = false;
240 240
 				}
241 241
 			} catch (FileNotFoundException $e) {
@@ -414,10 +414,10 @@  discard block
 block discarded – undo
414 414
 	 * @param  string  $algorithm  - Any algorithm supported by hash()
415 415
 	 * @return bool|string  return false on failure the hash output string on success
416 416
 	 */
417
-	public function hash($path, $algorithm='md5')
417
+	public function hash($path, $algorithm = 'md5')
418 418
 	{
419 419
 		if (!in_array($algorithm, hash_algos())) {
420
-			throw new \InvalidArgumentException('Hash algorithm ' . $algorithm . ' is not supported');
420
+			throw new \InvalidArgumentException('Hash algorithm '.$algorithm.' is not supported');
421 421
 		}
422 422
 		$stream = $this->_flysystem->readStream($path);
423 423
 		if ($stream === false) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -158,7 +158,9 @@
 block discarded – undo
158 158
 
159 159
 		$result = $this->put($path = trim($path), $stream, $visibility);
160 160
 
161
-		if (is_resource($stream)) fclose($stream);
161
+		if (is_resource($stream)) {
162
+			fclose($stream);
163
+		}
162 164
 
163 165
 		return $result ? (bool) $path : false;
164 166
 	}
Please login to merge, or discard this patch.
neon/firefly/services/driveManager/drivers/Db.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			->all();
184 184
 		$success = true;
185 185
 		foreach ($files as $file) {
186
-			if ( ! $this->delete($file['path'])) {
186
+			if (!$this->delete($file['path'])) {
187 187
 				$success = false;
188 188
 			}
189 189
 		}
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 			$query->where(['like', 'path', $directory]);
297 297
 		}
298 298
 		$result = $query->asArray()->limit(1000)->all();
299
-		$result = array_map(function($r){
299
+		$result = array_map(function($r) {
300 300
 			return DbFile::convertToFileSystemFormat($r);
301 301
 		}, $result);
302 302
 		return Util::emulateDirectories($result);
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	{
313 313
 		$path = rtrim($path, '/');
314 314
 		$sanitizedPath = addcslashes($path, '_%');
315
-		return $sanitizedPath . '/';
315
+		return $sanitizedPath.'/';
316 316
 	}
317 317
 
318 318
 	/**
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	 * @param  string  $path
397 397
 	 * @throws \neon\firefly\services\fileManager\FileExceedsMemoryLimitException
398 398
 	 */
399
-	protected function _checkFileSizeLimit($path, $message='')
399
+	protected function _checkFileSizeLimit($path, $message = '')
400 400
 	{
401 401
 		if (function_exists('ini_get')) {
402 402
 			$bytes = to_bytes(ini_get('memory_limit'));
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -203,8 +203,7 @@
 block discarded – undo
203 203
 		$file = DbFile::findOne($dirname);
204 204
 		if ($file === null) {
205 205
 			$file = new DbFile(['path' => $dirname]);
206
-		}
207
-		else if ($file->type == DbFile::TYPE_FILE) {
206
+		} else if ($file->type == DbFile::TYPE_FILE) {
208 207
 			throw new FileExistsException('Can not create a directory as a file already exists.');
209 208
 		}
210 209
 		if ($visibility = $config->get('visibility')) {
Please login to merge, or discard this patch.
neon/firefly/services/ImageManager.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 
38 38
 			if (Arr::get($params, 'fit', false)) {
39 39
 				// add callback functionality to retain maximal original image size
40
-				$image->fit($width, $height, function ($constraint) {
40
+				$image->fit($width, $height, function($constraint) {
41 41
 					$constraint->upsize();
42 42
 				});
43 43
 			} elseif ($width || $height) {
44
-				$image->resize($width, $height, function ($constraint) {
44
+				$image->resize($width, $height, function($constraint) {
45 45
 					$constraint->aspectRatio();
46 46
 					$constraint->upsize();
47 47
 				});
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 			$response = $image->response(null, $quality);
94 94
 
95
-		} catch(\Exception $e) {
95
+		} catch (\Exception $e) {
96 96
 			$imageContent = $this->getNotReadableImageContents();
97 97
 			return $imageContent;
98 98
 		}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function runFilter(Image $image, $filter)
108 108
 	{
109
-		$filters = explode(',',$filter);
109
+		$filters = explode(',', $filter);
110 110
 		if (in_array('greyscale', $filters, true)) {
111 111
 			$this->runGreyscaleFilter($image);
112 112
 		}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			$x = Arr::get($params, 'x', null);
159 159
 			$y = Arr::get($params, 'y', null);
160 160
 		}
161
-		if ($w == 0 && $h == 0 && $x == 0 && $y ==0) {
161
+		if ($w == 0 && $h == 0 && $x == 0 && $y == 0) {
162 162
 			return $image;
163 163
 		}
164 164
 		$image->crop($w, $h, $x, $y);
Please login to merge, or discard this patch.
neon/firefly/services/MediaManager.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		$bits = explode('/', $path);
75 75
 		$bitsCurrent = [];
76 76
 		$parts = [];
77
-		foreach($bits as $i => $bit) {
77
+		foreach ($bits as $i => $bit) {
78 78
 			$bitsCurrent[] = $bit;
79 79
 			if ($i == 0) continue;
80 80
 			$parts[] = implode('/', $bitsCurrent);
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	/**
110 110
 	 * @inheritDoc
111 111
 	 */
112
-	public function listContents($directory = '', $withDeleted=false)
112
+	public function listContents($directory = '', $withDeleted = false)
113 113
 	{
114 114
 		$directory = $this->getRealPath($directory);
115 115
 		$item = Media::findDirectoryByPath($directory, $withDeleted);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 			->asArray();
126 126
 		$items = $query->all();
127 127
 
128
-		foreach($items as $key => $item) {
128
+		foreach ($items as $key => $item) {
129 129
 			$items[$key]['path'] = Media::formatPath($item['path']);
130 130
 		}
131 131
 		return $items;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	/**
135 135
 	 * @inheritDoc
136 136
 	 */
137
-	public function addFile($id, $path='/')
137
+	public function addFile($id, $path = '/')
138 138
 	{
139 139
 		// Find the file
140 140
 		$fileMeta = neon()->firefly->getMeta($id);
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function setRootPath($path)
242 242
 	{
243
-		$this->_rootPath = rtrim($path, '/') . '/';
243
+		$this->_rootPath = rtrim($path, '/').'/';
244 244
 	}
245 245
 
246 246
 	/**
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		$items = Media::findAll(['id' => $items]);
299 299
 		// update each item
300 300
 		$success = [];
301
-		foreach($items as $item) {
301
+		foreach ($items as $item) {
302 302
 			$success[] = $item->moveInto($into);
303 303
 		}
304 304
 		return !in_array(false, $success);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function getRealPath($path)
316 316
 	{
317
-		$path = $this->getRootPath() . ltrim($path, '/');
317
+		$path = $this->getRootPath().ltrim($path, '/');
318 318
 		return strlen($path) === 1 ? '/' : rtrim($path, '/');
319 319
 	}
320 320
 }
Please login to merge, or discard this patch.
Braces   +32 added lines, -21 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
46 46
 		}, $paths);
47 47
 
48 48
 		if (empty($created)) {
49
-			if ($directory == '')
50
-				throw new DirectoryExistsException("The root directory already exists");
49
+			if ($directory == '') {
50
+							throw new DirectoryExistsException("The root directory already exists");
51
+			}
51 52
 			throw new DirectoryExistsException("The directory '$directory' already exists");
52 53
 		}
53 54
 		return $created;
@@ -76,7 +77,9 @@  discard block
 block discarded – undo
76 77
 		$parts = [];
77 78
 		foreach($bits as $i => $bit) {
78 79
 			$bitsCurrent[] = $bit;
79
-			if ($i == 0) continue;
80
+			if ($i == 0) {
81
+				continue;
82
+			}
80 83
 			$parts[] = implode('/', $bitsCurrent);
81 84
 		}
82 85
 		return $parts;
@@ -90,11 +93,13 @@  discard block
 block discarded – undo
90 93
 	public function validateAbsoluteDirectoryPath($directory)
91 94
 	{
92 95
 		// must be absolute and start with /
93
-		if ($directory[0] !== '/')
94
-			throw new InvalidDirectoryException("Invalid directory parameter '$directory'. The directory must be absolute path and start with '/'.");
96
+		if ($directory[0] !== '/') {
97
+					throw new InvalidDirectoryException("Invalid directory parameter '$directory'. The directory must be absolute path and start with '/'.");
98
+		}
95 99
 		// prevent folders with no names being created
96
-		if (strpos($directory, '//') !== false)
97
-			throw new InvalidDirectoryException("Invalid directory parameter '$directory'. You can not have empty path sections containing '//' each directory needs a name.");
100
+		if (strpos($directory, '//') !== false) {
101
+					throw new InvalidDirectoryException("Invalid directory parameter '$directory'. You can not have empty path sections containing '//' each directory needs a name.");
102
+		}
98 103
 	}
99 104
 
100 105
 	/**
@@ -170,10 +175,11 @@  discard block
 block discarded – undo
170 175
 			throw new BadRequestHttpException('A name cannot contain a "/" character');
171 176
 		}
172 177
 
173
-		if ($node->isDir())
174
-			$this->_updateDirectoryName($node, $name);
175
-		else
176
-			$this->_updateFileName($node, $name);
178
+		if ($node->isDir()) {
179
+					$this->_updateDirectoryName($node, $name);
180
+		} else {
181
+					$this->_updateFileName($node, $name);
182
+		}
177 183
 		return true;
178 184
 	}
179 185
 
@@ -249,8 +255,9 @@  discard block
 block discarded – undo
249 255
 	public function getDirectoryMeta($path)
250 256
 	{
251 257
 		$dir = Media::findDirectoryByPath($path);
252
-		if ($dir === null)
253
-			return null;
258
+		if ($dir === null) {
259
+					return null;
260
+		}
254 261
 		return $dir->toArray();
255 262
 	}
256 263
 
@@ -260,8 +267,9 @@  discard block
 block discarded – undo
260 267
 	public function delete($id)
261 268
 	{
262 269
 		$item = Media::findOne($id);
263
-		if ($item === null)
264
-			throw new NotFoundHttpException("No item with id '$id' could be found'");
270
+		if ($item === null) {
271
+					throw new NotFoundHttpException("No item with id '$id' could be found'");
272
+		}
265 273
 		$result = $item->delete();
266 274
 		if ($result === false) {
267 275
 			return $item->getErrors();
@@ -275,8 +283,9 @@  discard block
 block discarded – undo
275 283
 	public function destroy($id)
276 284
 	{
277 285
 		$item = Media::findWithDeleted()->where(['id' => $id])->one();
278
-		if ($item === null)
279
-			throw new NotFoundHttpException("No item with id '$id' could be found'");
286
+		if ($item === null) {
287
+					throw new NotFoundHttpException("No item with id '$id' could be found'");
288
+		}
280 289
 		return $item->destroy();
281 290
 	}
282 291
 
@@ -288,11 +297,13 @@  discard block
 block discarded – undo
288 297
 		// get the "into" folder
289 298
 		$into = Media::findOne($intoId);
290 299
 		// throw error if it doesn't exist
291
-		if ($into === null)
292
-			throw new NotFoundHttpException("No item with id '$intoId' could be found'");
300
+		if ($into === null) {
301
+					throw new NotFoundHttpException("No item with id '$intoId' could be found'");
302
+		}
293 303
 		// throw error if its not a directory
294
-		if (!$into->isDir())
295
-			throw new BadRequestHttpException("This is not a directory - you can only move items into directories");
304
+		if (!$into->isDir()) {
305
+					throw new BadRequestHttpException("This is not a directory - you can only move items into directories");
306
+		}
296 307
 
297 308
 		// find all items to move
298 309
 		$items = Media::findAll(['id' => $items]);
Please login to merge, or discard this patch.
neon/firefly/services/fileManager/interfaces/IFileManager.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 *   'h' => height
125 125
 	 * @return string
126 126
 	 */
127
-	public function getImage($uuid, $params=[]);
127
+	public function getImage($uuid, $params = []);
128 128
 
129 129
 	/**
130 130
 	 * Get a file's visibility.
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * - otherwise it will just return the value from the database
206 206
 	 * @return string the md5 checksum of the file contents
207 207
 	 */
208
-	public function getFileHash($uuid, $refresh=false);
208
+	public function getFileHash($uuid, $refresh = false);
209 209
 
210 210
 	/**
211 211
 	 * Get the file size in bytes
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * If false will display the file in the browser
234 234
 	 * @return Response
235 235
 	 */
236
-	public function sendFile($uuid, $download=false);
236
+	public function sendFile($uuid, $download = false);
237 237
 
238 238
 	/**
239 239
 	 * Find a file manager file data by its drive and path location
Please login to merge, or discard this patch.
neon/firefly/services/DriveManager.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -179,11 +179,11 @@
 block discarded – undo
179 179
 
180 180
 		// get the adapter driver for the drive (e.g. S3 | local)
181 181
 		$configObj = (new $driver($config));
182
-		if ( ! $configObj instanceof IDriverConfig) {
182
+		if (!$configObj instanceof IDriverConfig) {
183 183
 			throw new \InvalidArgumentException('The driver specified is not a valid implementation of \neon\firefly\services\fileSystem\interfaces\IDriverConfig');
184 184
 		}
185 185
 		$driverObj = $configObj->getAdapter();
186
-		if ( ! $driverObj instanceof AdapterInterface) {
186
+		if (!$driverObj instanceof AdapterInterface) {
187 187
 			throw new \InvalidArgumentException('The driver config object ('.$driver.') does not provide a valid driver implementing \League\Flysystem\AdapterInterface');
188 188
 		}
189 189
 		// get the generic Filesystem adapter
Please login to merge, or discard this patch.
neon/firefly/services/FileManager.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	/**
135 135
 	 * @inheritdoc
136 136
 	 */
137
-	public function getImage($uuid, $params=[])
137
+	public function getImage($uuid, $params = [])
138 138
 	{
139 139
 		$p = array_merge(['/firefly/file/img', 'id'=>$uuid], $params);
140 140
 		return Url::to($p, true);
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	/**
246 246
 	 * @inheritdoc
247 247
 	 */
248
-	public function sendFile($uuid, $download=false)
248
+	public function sendFile($uuid, $download = false)
249 249
 	{
250 250
 		$meta = $this->getMeta($uuid);
251 251
 		$drive = $this->getDriveFor($uuid, $file);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	public function getFileName($uuid)
287 287
 	{
288 288
 		$meta = $this->getMeta($uuid);
289
-		return isset($meta['name']) ? $meta['name'] : false ;
289
+		return isset($meta['name']) ? $meta['name'] : false;
290 290
 	}
291 291
 
292 292
 	/**
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	public function getSize($uuid)
310 310
 	{
311 311
 		$meta = $this->getMeta($uuid);
312
-		return isset($meta['size']) ? $meta['size'] : false ;
312
+		return isset($meta['size']) ? $meta['size'] : false;
313 313
 	}
314 314
 
315 315
 	/**
@@ -380,16 +380,16 @@  discard block
 block discarded – undo
380 380
 	 * @param  string  $name  - The actual file name
381 381
 	 * @return  string  - The full file past on the drive
382 382
 	 */
383
-	protected function _generatePath(&$name=null, $fm)
383
+	protected function _generatePath(&$name = null, $fm)
384 384
 	{
385 385
 		$info = pathinfo($name);
386 386
 		$fileName = $info['filename'];
387
-		$extension = isset($info['extension']) ? '.' . $info['extension'] : '';
387
+		$extension = isset($info['extension']) ? '.'.$info['extension'] : '';
388 388
 		if (empty($fileName)) {
389 389
 			$fileName = 'nameless';
390 390
 			$name = 'nameless';
391 391
 		}
392
-		return date('Y') . '/' . date('m') . '/' . $fileName . '.' . $fm->uuid . $extension;
392
+		return date('Y').'/'.date('m').'/'.$fileName.'.'.$fm->uuid.$extension;
393 393
 	}
394 394
 
395 395
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@  discard block
 block discarded – undo
66 66
 		neon()->firefly->isFileObjectValid($file);
67 67
 		$stream = fopen($file->getRealPath(), 'r+');
68 68
 		$uuid = $this->save($stream, $file->getFilename(), $meta);
69
-		if (is_resource($stream)) fclose($stream);
69
+		if (is_resource($stream)) {
70
+			fclose($stream);
71
+		}
70 72
 		return $uuid;
71 73
 	}
72 74
 
@@ -336,8 +338,9 @@  discard block
 block discarded – undo
336 338
 	public function findFile($drive, $path)
337 339
 	{
338 340
 		$model = Model::find()->where(['drive' => $drive, 'path' => $path])->one();
339
-		if ($model === null)
340
-			return null;
341
+		if ($model === null) {
342
+					return null;
343
+		}
341 344
 		return $model->toArray();
342 345
 	}
343 346
 
Please login to merge, or discard this patch.
neon/firefly/services/plupload/Receiver.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -51,68 +51,68 @@  discard block
 block discarded – undo
51 51
 	 * Receiver constructor.
52 52
 	 * @param Request $request
53 53
 	 */
54
-    public function __construct(Request $request)
55
-    {
56
-        $this->_request = $request;
57
-    }
54
+	public function __construct(Request $request)
55
+	{
56
+		$this->_request = $request;
57
+	}
58 58
 
59
-    /**
60
-     * Get the temporary path where plupload will store the file uploads
61
-     * @return string - writable directory path
62
-     */
63
-    public function getPath()
64
-    {
65
-        $path = neon()->getAlias('@runtime/plupload');
66
-        if (!is_dir($path)) {
67
-            mkdir($path, 0755, true);
68
-        }
69
-        return $path;
70
-    }
59
+	/**
60
+	 * Get the temporary path where plupload will store the file uploads
61
+	 * @return string - writable directory path
62
+	 */
63
+	public function getPath()
64
+	{
65
+		$path = neon()->getAlias('@runtime/plupload');
66
+		if (!is_dir($path)) {
67
+			mkdir($path, 0755, true);
68
+		}
69
+		return $path;
70
+	}
71 71
 
72
-    /**
73
-     * Whether the plupload upload will be uploaded in chunks
74
-     * @return bool
75
-     */
76
-    public function hasChunks()
77
-    {
78
-        return (bool) $this->_request->getBodyParam('chunks', false);
79
-    }
72
+	/**
73
+	 * Whether the plupload upload will be uploaded in chunks
74
+	 * @return bool
75
+	 */
76
+	public function hasChunks()
77
+	{
78
+		return (bool) $this->_request->getBodyParam('chunks', false);
79
+	}
80 80
 
81
-    /**
82
-     * Receive a plupload upload
83
-     * @param string $name  - Name of the request variable that holds
84
-     * the plupload file(s) - typically the name of the plupload input field
85
-     * @param  \Closure  $handler  - A handler function that is passed the uploaded file
86
-     * method signature is: function(\neon\core\web\UploadedFile $file) {}
87
-     * @return array  - return the result of the upload back to plupload, this should be json encoded
88
-     */
89
-    public function receive($name, \Closure $handler)
90
-    {
91
-        $response = [];
92
-        $response['jsonrpc'] = '2.0';
93
-        if ($this->hasChunks()) {
94
-            $result = $this->receiveChunks($name, $handler);
95
-        } else {
96
-            $result = $this->receiveSingle($name, $handler);
97
-        }
98
-        $response['result'] = $result;
99
-	    $response['id'] = 'plup';
100
-        return $response;
101
-    }
81
+	/**
82
+	 * Receive a plupload upload
83
+	 * @param string $name  - Name of the request variable that holds
84
+	 * the plupload file(s) - typically the name of the plupload input field
85
+	 * @param  \Closure  $handler  - A handler function that is passed the uploaded file
86
+	 * method signature is: function(\neon\core\web\UploadedFile $file) {}
87
+	 * @return array  - return the result of the upload back to plupload, this should be json encoded
88
+	 */
89
+	public function receive($name, \Closure $handler)
90
+	{
91
+		$response = [];
92
+		$response['jsonrpc'] = '2.0';
93
+		if ($this->hasChunks()) {
94
+			$result = $this->receiveChunks($name, $handler);
95
+		} else {
96
+			$result = $this->receiveSingle($name, $handler);
97
+		}
98
+		$response['result'] = $result;
99
+		$response['id'] = 'plup';
100
+		return $response;
101
+	}
102 102
 
103
-    /**
104
-     * Process single file upload
105
-     * @param string $name
106
-     * @param \Closure $handler - function to call on successful upload completed
107
-     * @return bool|mixed
108
-     */
109
-    public function receiveSingle($name, \Closure $handler)
110
-    {
111
-        if ($this->_request->file($name)) {
112
-            return $handler($this->_request->file($name));
113
-        }
114
-        return false;
115
-    }
103
+	/**
104
+	 * Process single file upload
105
+	 * @param string $name
106
+	 * @param \Closure $handler - function to call on successful upload completed
107
+	 * @return bool|mixed
108
+	 */
109
+	public function receiveSingle($name, \Closure $handler)
110
+	{
111
+		if ($this->_request->file($name)) {
112
+			return $handler($this->_request->file($name));
113
+		}
114
+		return false;
115
+	}
116 116
 
117 117
 	/**
118 118
 	 * Process chunked file upload
@@ -121,30 +121,30 @@  discard block
 block discarded – undo
121 121
 	 * @throws \Exception
122 122
 	 * @return bool
123 123
 	 */
124
-    public function receiveChunks($name, $handler)
125
-    {
126
-        $result = false;
127
-        if ($this->_request->file($name)) {
128
-            $file = $this->_request->file($name);
129
-            $chunk = (int) $this->_request->getBodyParam("chunk", 0);
130
-            $chunks = (int) $this->_request->getBodyParam("chunks", 0 );
131
-            $originalName = $this->_request->getBodyParam('name');
132
-            $filePath = $this->getPath().'/'.$originalName.'.part';
133
-            $this->_removeOldData($filePath);
134
-            $this->_appendData($filePath, $file);
135
-            if ($chunk == $chunks - 1) {
136
-                $file = new UploadedFile([
137
-                    'name' => $originalName,
138
-                    'size' => filesize($filePath),
139
-                    'tempName' => $filePath,
140
-                    'error' => UPLOAD_ERR_OK
141
-                ]);
142
-                $result = $handler($file);
143
-                unlink($filePath);
144
-            }
145
-        }
146
-        return $result;
147
-    }
124
+	public function receiveChunks($name, $handler)
125
+	{
126
+		$result = false;
127
+		if ($this->_request->file($name)) {
128
+			$file = $this->_request->file($name);
129
+			$chunk = (int) $this->_request->getBodyParam("chunk", 0);
130
+			$chunks = (int) $this->_request->getBodyParam("chunks", 0 );
131
+			$originalName = $this->_request->getBodyParam('name');
132
+			$filePath = $this->getPath().'/'.$originalName.'.part';
133
+			$this->_removeOldData($filePath);
134
+			$this->_appendData($filePath, $file);
135
+			if ($chunk == $chunks - 1) {
136
+				$file = new UploadedFile([
137
+					'name' => $originalName,
138
+					'size' => filesize($filePath),
139
+					'tempName' => $filePath,
140
+					'error' => UPLOAD_ERR_OK
141
+				]);
142
+				$result = $handler($file);
143
+				unlink($filePath);
144
+			}
145
+		}
146
+		return $result;
147
+	}
148 148
 
149 149
 	/**
150 150
 	 * Todo: requires test
@@ -164,15 +164,15 @@  discard block
 block discarded – undo
164 164
 	 * @param string $path Optional firefly media virtual path
165 165
 	 * @return array
166 166
 	 */
167
-    public function receiveToFirefly($name, $path='/')
168
-    {
169
-    	return $this->receive($name, function (UploadedFile $file) use ($path) {
170
-    		// save file to firefly
171
-		    $id = neon()->firefly->fileManager->saveFile($file);
172
-		    $meta = neon()->firefly->mediaManager->addFile($id, $path);
173
-		    return $meta;
174
-	    });
175
-    }
167
+	public function receiveToFirefly($name, $path='/')
168
+	{
169
+		return $this->receive($name, function (UploadedFile $file) use ($path) {
170
+			// save file to firefly
171
+			$id = neon()->firefly->fileManager->saveFile($file);
172
+			$meta = neon()->firefly->mediaManager->addFile($id, $path);
173
+			return $meta;
174
+		});
175
+	}
176 176
 
177 177
 	/**
178 178
 	 * Receives a file and saves it to firefly file manager only.
@@ -206,29 +206,29 @@  discard block
 block discarded – undo
206 206
 	 * @param UploadedFile $file
207 207
 	 * @throws PluploadException
208 208
 	 */
209
-    protected function _appendData($filePathPartial, UploadedFile $file)
210
-    {
211
-        if (!$out = fopen($filePathPartial, 'ab')) {
212
-            throw new PluploadException('Failed to open output stream.', 102);
213
-        }
214
-        if (!$in = fopen($file->getRealPath(), 'rb')) {
215
-            throw new PluploadException('Failed to open input stream', 101);
216
-        }
217
-        while ($buff = fread($in, 4096)) {
218
-            fwrite($out, $buff);
219
-        }
220
-        fclose($out);
221
-        fclose($in);
222
-    }
209
+	protected function _appendData($filePathPartial, UploadedFile $file)
210
+	{
211
+		if (!$out = fopen($filePathPartial, 'ab')) {
212
+			throw new PluploadException('Failed to open output stream.', 102);
213
+		}
214
+		if (!$in = fopen($file->getRealPath(), 'rb')) {
215
+			throw new PluploadException('Failed to open input stream', 101);
216
+		}
217
+		while ($buff = fread($in, 4096)) {
218
+			fwrite($out, $buff);
219
+		}
220
+		fclose($out);
221
+		fclose($in);
222
+	}
223 223
 
224 224
 	/**
225 225
 	 * Remove old files
226 226
 	 * @param string $filePath
227 227
 	 */
228
-    protected function _removeOldData($filePath)
229
-    {
230
-        if (file_exists($filePath) && filemtime($filePath) < time() - $this->maxFileAge) {
231
-            unlink($filePath);
232
-        }
233
-    }
228
+	protected function _removeOldData($filePath)
229
+	{
230
+		if (file_exists($filePath) && filemtime($filePath) < time() - $this->maxFileAge) {
231
+			unlink($filePath);
232
+		}
233
+	}
234 234
 }
235 235
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         if ($this->_request->file($name)) {
128 128
             $file = $this->_request->file($name);
129 129
             $chunk = (int) $this->_request->getBodyParam("chunk", 0);
130
-            $chunks = (int) $this->_request->getBodyParam("chunks", 0 );
130
+            $chunks = (int) $this->_request->getBodyParam("chunks", 0);
131 131
             $originalName = $this->_request->getBodyParam('name');
132 132
             $filePath = $this->getPath().'/'.$originalName.'.part';
133 133
             $this->_removeOldData($filePath);
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	 * @param string $path Optional firefly media virtual path
165 165
 	 * @return array
166 166
 	 */
167
-    public function receiveToFirefly($name, $path='/')
167
+    public function receiveToFirefly($name, $path = '/')
168 168
     {
169
-    	return $this->receive($name, function (UploadedFile $file) use ($path) {
169
+    	return $this->receive($name, function(UploadedFile $file) use ($path) {
170 170
     		// save file to firefly
171 171
 		    $id = neon()->firefly->fileManager->saveFile($file);
172 172
 		    $meta = neon()->firefly->mediaManager->addFile($id, $path);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	public function receiveToFireflyFileManager($name)
195 195
 	{
196
-		return $this->receive($name, function (UploadedFile $file)  {
196
+		return $this->receive($name, function(UploadedFile $file) {
197 197
 			// save file to firefly
198 198
 			$id = neon()->firefly->fileManager->saveFile($file);
199 199
 			return neon()->firefly->fileManager->getMeta($id);
Please login to merge, or discard this patch.
neon/firefly/controllers/FileController.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
 	 * Send appropriate cache headers
139 139
 	 * @param string $mime - mime type of file
140 140
 	 * @param string|int $size - size in bytes of response
141
- 	 * @param string $modified - MySQL Datetime
141
+	 * @param string $modified - MySQL Datetime
142 142
 	 * @param string $eTag - eTag token header to use
143 143
 	 * @param string $name - filename string to use in content disposition header
144 144
 	 */
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		$id = $request->get('id');
31 31
 		if (!$firefly->fileManager->exists($id)) {
32 32
 			// show placeholder image - should be handled by image manager - controllers should not know
33
-			return neon()->response->sendFile(dirname(__DIR__) . '/assets/placeholder.jpg', 'No File', ['inline' => true]);
33
+			return neon()->response->sendFile(dirname(__DIR__).'/assets/placeholder.jpg', 'No File', ['inline' => true]);
34 34
 		}
35 35
 
36 36
 		// as the url is unique for a file we can be aggressive about caching
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 			return $firefly->fileManager->sendFile($id, (bool) $download);
47 47
 		} catch (\Exception $e) {
48 48
 			// if path unknown respond with a blank placeholder
49
-			return neon()->response->sendFile(dirname(__DIR__) . '/assets/placeholder.jpg', 'No File', ['inline' => true]);
49
+			return neon()->response->sendFile(dirname(__DIR__).'/assets/placeholder.jpg', 'No File', ['inline' => true]);
50 50
 		}
51 51
 	}
52 52
 
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 		if (!$firefly->fileManager->exists($id)) {
74 74
 			// throw new HttpException(404);
75 75
 			// show placeholder image - should be handled by image manager - controllers should not know
76
-			return neon()->response->sendFile(dirname(__DIR__) . '/assets/placeholder.jpg', 'No File', ['inline' => true]);
76
+			return neon()->response->sendFile(dirname(__DIR__).'/assets/placeholder.jpg', 'No File', ['inline' => true]);
77 77
 		}
78 78
 
79 79
 		// create a unique request key - add v2 to force use of new cached versioning
80
-		$requestKey = $request->absoluteUrl . "v2";
80
+		$requestKey = $request->absoluteUrl."v2";
81 81
 
82 82
 		// check this is an image before continuing - type image and not svg
83 83
 		// Handle SVG images correctly (we do not need to process vector images)
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function generatePublicFile($id, $imageContent)
127 127
 	{
128
-		$dir = substr($id,0, 3);
128
+		$dir = substr($id, 0, 3);
129 129
 		$publicDir = neon()->getAlias("@webroot/assets/firefly/$dir");
130 130
 		if (!file_exists($publicDir)) {
131 131
 			FileHelper::createDirectory($publicDir);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * Handle a request that can return a 304 not modified header
161 161
 	 * @param bool|string $cacheKey - default false - if cache key is specified
162 162
 	 */
163
-	public function handleNotModified($cacheKey=false)
163
+	public function handleNotModified($cacheKey = false)
164 164
 	{
165 165
 		$requestHeaders = neon()->request->headers;
166 166
 		$browserHasCache = (isset($requestHeaders['If-Modified-Since']) || isset($requestHeaders['If-None-Match']));
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	{
177 177
 		header($_SERVER['SERVER_PROTOCOL'].' 304 Not modified');
178 178
 		header('Cache-Control: private, max-age=30000000, immutable, only-if-cached');
179
-		header('Expires: ' . Carbon::now()->addYear(10)->toRfc1123String());
179
+		header('Expires: '.Carbon::now()->addYear(10)->toRfc1123String());
180 180
 		exit;
181 181
 	}
182 182
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,8 +82,9 @@
 block discarded – undo
82 82
 		// check this is an image before continuing - type image and not svg
83 83
 		// Handle SVG images correctly (we do not need to process vector images)
84 84
 		$meta = $firefly->fileManager->getMeta($id);
85
-		if (strpos($meta['mime_type'], 'image') === false || strpos($meta['mime_type'], 'svg') !== false)
86
-			return $this->actionGet();
85
+		if (strpos($meta['mime_type'], 'image') === false || strpos($meta['mime_type'], 'svg') !== false) {
86
+					return $this->actionGet();
87
+		}
87 88
 
88 89
 		// see if we already have this in cache and the browser already has it too
89 90
 		// We want to remove the need to process images when ever possible
Please login to merge, or discard this patch.