Passed
Push — develop ( 319bd8...330c7a )
by Neill
16:41 queued 15s
created
neon/utilities/controllers/ClearCacheController.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		$cmp = neon()->getApp($app)->get($component);
34 34
 		if ($cmp !== null && $cmp instanceof CacheInterface) {
35 35
 			if ($cmp->flush()) {
36
-				neon()->session->setFlash('success', $component . ' cache successfully flushed');
36
+				neon()->session->setFlash('success', $component.' cache successfully flushed');
37 37
 				return $this->redirect(['/utilities/clear-cache/index']);
38 38
 			}
39 39
 		}
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 	public function actionClearAll()
66 66
 	{
67 67
 		$caches = $this->getCaches();
68
-		foreach($caches as $app => $caches) {
68
+		foreach ($caches as $app => $caches) {
69 69
 			$a = neon()->getApp($app);
70 70
 			if ($a === null) return;
71
-			foreach($caches as $name => $component) {
71
+			foreach ($caches as $name => $component) {
72 72
 				$cmp = $a->get($name);
73 73
 				if ($cmp !== null && $cmp instanceof CacheInterface) {
74 74
 					$cmp->flush();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		$r = new Renderer();
93 93
 		$r->smarty->clearCompiledTemplate();
94 94
 		$r->smarty->clearAllCache();
95
-		foreach(neon()->view->renderers as $ext => $config) {
95
+		foreach (neon()->view->renderers as $ext => $config) {
96 96
 			$renderer = neon()->view->getRendererByExtension($ext);
97 97
 			if ($renderer instanceof ICanFlushTemplates) {
98 98
 				$renderer->flushTemplates();
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,7 +67,9 @@  discard block
 block discarded – undo
67 67
 		$caches = $this->getCaches();
68 68
 		foreach($caches as $app => $caches) {
69 69
 			$a = neon()->getApp($app);
70
-			if ($a === null) return;
70
+			if ($a === null) {
71
+				return;
72
+			}
71 73
 			foreach($caches as $name => $component) {
72 74
 				$cmp = $a->get($name);
73 75
 				if ($cmp !== null && $cmp instanceof CacheInterface) {
@@ -132,7 +134,9 @@  discard block
 block discarded – undo
132 134
 	public function getCaches()
133 135
 	{
134 136
 		return collect(neon()->getAllApps())->map(function($config, $app) {
135
-			$a = neon()->getApp($app); if ($a === null) return;
137
+			$a = neon()->getApp($app); if ($a === null) {
138
+				return;
139
+			}
136 140
 			return $this->getCacheComponents($a->getComponents());
137 141
 		})
138 142
 		->put('neon', $this->getCacheComponents(neon()->getComponents()))
Please login to merge, or discard this patch.
neon/utilities/controllers/requirements.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
 function maxExecutionTimeRequirement()
9 9
 {
10
-	$maxExecutionTime = (int)trim(ini_get('max_execution_time'));
10
+	$maxExecutionTime = (int) trim(ini_get('max_execution_time'));
11 11
 
12
-	$humanTime = $maxExecutionTime . ($maxExecutionTime === 0 ? ' (no limit)' : '');
12
+	$humanTime = $maxExecutionTime.($maxExecutionTime === 0 ? ' (no limit)' : '');
13 13
 	$memo = "Neon requires a minimum PHP max execution time of 120 seconds. The max_execution_time directive in php.ini is currently set to {$humanTime}.";
14 14
 
15 15
 	return array(
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	$memoryLimit = ini_get('memory_limit');
26 26
 	$bytes = getByteSize($memoryLimit);
27 27
 
28
-	$humanLimit = $memoryLimit . ($memoryLimit === -1 ? ' (no limit)' : '');
28
+	$humanLimit = $memoryLimit.($memoryLimit === -1 ? ' (no limit)' : '');
29 29
 	$memo = "Neon requires a minimum PHP memory limit of 256M. The memory_limit directive in php.ini is currently set to {$humanLimit}.";
30 30
 
31 31
 	return array(
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 {
68 68
 	// Copied from craft\helpers\App::phpConfigValueInBytes()
69 69
 	if (!preg_match('/(\d+)(K|M|G)/i', $value, $matches)) {
70
-		return (int)$value;
70
+		return (int) $value;
71 71
 	}
72 72
 
73
-	$value = (int)$matches[1];
73
+	$value = (int) $matches[1];
74 74
 
75 75
 	// Multiply!
76 76
 	switch (strtolower($matches[2])) {
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         (for example, plural in
259 259
         <a href=\"http://www.yiiframework.com/doc-2.0/yii-i18n-formatter.html#asRelativeTime%28%29-detail\">
260 260
         Formatter::asRelativeTime()</a>) in the <code>yii\i18n\Formatter</code> class. Your current ICU version is ' .
261
-			(defined('INTL_ICU_VERSION') ? INTL_ICU_VERSION : '(ICU is missing)') . '.'
261
+			(defined('INTL_ICU_VERSION') ? INTL_ICU_VERSION : '(ICU is missing)').'.'
262 262
 	],
263 263
 	[
264 264
 		'name' => 'ICU Data version',
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
         (for example, plural in
270 270
         <a href=\"http://www.yiiframework.com/doc-2.0/yii-i18n-formatter.html#asRelativeTime%28%29-detail\">
271 271
         Formatter::asRelativeTime()</a>) in the <code>yii\i18n\Formatter</code> class. Your current ICU Data version is ' .
272
-			(defined('INTL_ICU_DATA_VERSION') ? INTL_ICU_DATA_VERSION : '(ICU Data is missing)') . '.'
272
+			(defined('INTL_ICU_DATA_VERSION') ? INTL_ICU_DATA_VERSION : '(ICU Data is missing)').'.'
273 273
 	],
274 274
 	[
275 275
 		'name' => 'Parse Ini File',
Please login to merge, or discard this patch.
neon/utilities/App.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
 	public function checkAuthorization(string $class): bool
90 90
 	{
91 91
 		/** @var string|IUtilitiy $class */
92
-		return neon()->getUser()->checkPermission('utility:' . $class::id());
92
+		return neon()->getUser()->checkPermission('utility:'.$class::id());
93 93
 	}
94 94
 
95 95
 	/**
Please login to merge, or discard this patch.
neon/firefly/services/FileManager.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
 		$q = new Query();
108 108
 		foreach ($all as $i => $field) {
109 109
 			if ($i === 0) {
110
-				$q->select(['_uuid'],"'$field[class_type]' as 'class',")
111
-					->from('ddt_' . $field['class_type'])
110
+				$q->select(['_uuid'], "'$field[class_type]' as 'class',")
111
+					->from('ddt_'.$field['class_type'])
112 112
 					->where([$field['member_ref'] => $uuid]);
113 113
 			} else {
114
-				$q->union((new Query())->select(['_uuid'],"'$field[class_type]' as 'class',")
115
-					->from('ddt_' . $field['class_type'])
114
+				$q->union((new Query())->select(['_uuid'], "'$field[class_type]' as 'class',")
115
+					->from('ddt_'.$field['class_type'])
116 116
 					->where([$field['member_ref'] => $uuid]));
117 117
 			}
118 118
 		}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	/**
184 184
 	 * @inheritdoc
185 185
 	 */
186
-	public function getImage($uuid, $params=[])
186
+	public function getImage($uuid, $params = [])
187 187
 	{
188 188
 		$p = array_merge(['/firefly/file/img', 'id'=>$uuid], $params);
189 189
 		return Url::to($p, true);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		try {
235 235
 			$f = $this->_get($uuid);
236 236
 			return $f->delete();
237
-		} catch(FileNotFoundException $e) {
237
+		} catch (FileNotFoundException $e) {
238 238
 			return false;
239 239
 		}
240 240
 	}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	/**
300 300
 	 * @inheritdoc
301 301
 	 */
302
-	public function sendFile($uuid, $download=false)
302
+	public function sendFile($uuid, $download = false)
303 303
 	{
304 304
 		$meta = $this->getMeta($uuid);
305 305
 		$drive = $this->getDriveFor($uuid, $file);
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	public function getFileName($uuid)
342 342
 	{
343 343
 		$meta = $this->getMeta($uuid);
344
-		return isset($meta['name']) ? $meta['name'] : false ;
344
+		return isset($meta['name']) ? $meta['name'] : false;
345 345
 	}
346 346
 
347 347
 	/**
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	public function getSize($uuid)
365 365
 	{
366 366
 		$meta = $this->getMeta($uuid);
367
-		return isset($meta['size']) ? $meta['size'] : false ;
367
+		return isset($meta['size']) ? $meta['size'] : false;
368 368
 	}
369 369
 
370 370
 	/**
@@ -435,16 +435,16 @@  discard block
 block discarded – undo
435 435
 	 * @param  string  $name  - The actual file name
436 436
 	 * @return  string  - The full file past on the drive
437 437
 	 */
438
-	protected function _generatePath(&$name=null, $fm)
438
+	protected function _generatePath(&$name = null, $fm)
439 439
 	{
440 440
 		$info = pathinfo($name);
441 441
 		$fileName = $info['filename'];
442
-		$extension = isset($info['extension']) ? '.' . $info['extension'] : '';
442
+		$extension = isset($info['extension']) ? '.'.$info['extension'] : '';
443 443
 		if (empty($fileName)) {
444 444
 			$fileName = 'nameless';
445 445
 			$name = 'nameless';
446 446
 		}
447
-		return date('Y') . '/' . date('m') . '/' . $fileName . '.' . $fm->uuid . $extension;
447
+		return date('Y').'/'.date('m').'/'.$fileName.'.'.$fm->uuid.$extension;
448 448
 	}
449 449
 
450 450
 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 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
 
@@ -105,8 +107,9 @@  discard block
 block discarded – undo
105 107
 			->orWhere(['data_type_ref' => 'file_ref_multi'])
106 108
 			->all();
107 109
 			
108
-		if (empty($all))
109
-			return [];
110
+		if (empty($all)) {
111
+					return [];
112
+		}
110 113
 
111 114
 		$q = new Query();
112 115
 		foreach ($all as $i => $field) {
@@ -249,7 +252,9 @@  discard block
 block discarded – undo
249 252
 	public function destroy($uuid)
250 253
 	{
251 254
 		$file = Model::findWithDeleted()->where(['uuid' => $uuid])->one();
252
-		if ($file === null) return false;
255
+		if ($file === null) {
256
+			return false;
257
+		}
253 258
 		return $file->destroy();
254 259
 	}
255 260
 
@@ -332,7 +337,9 @@  discard block
 block discarded – undo
332 337
 			$driver = $this->getDriveFor($uuid, $file);
333 338
 			$hash = $driver->hash($file['path']);
334 339
 			$model = $this->_get($uuid);
335
-			if (!$hash) return false;
340
+			if (!$hash) {
341
+				return false;
342
+			}
336 343
 			$model->file_hash = $hash;
337 344
 			$model->save();
338 345
 		}
@@ -396,8 +403,9 @@  discard block
 block discarded – undo
396 403
 	{
397 404
 		$model = $this->_get($uuid);
398 405
 		$model->attributes = $updates;
399
-		if (!$model->save())
400
-			throw new HttpException(400, $model->getErrors());
406
+		if (!$model->save()) {
407
+					throw new HttpException(400, $model->getErrors());
408
+		}
401 409
 		return $model->toArray();
402 410
 	}
403 411
 
@@ -411,8 +419,9 @@  discard block
 block discarded – undo
411 419
 	public function findFile($drive, $path)
412 420
 	{
413 421
 		$model = Model::find()->where(['drive' => $drive, 'path' => $path])->one();
414
-		if ($model === null)
415
-			return null;
422
+		if ($model === null) {
423
+					return null;
424
+		}
416 425
 		return $model->toArray();
417 426
 	}
418 427
 
Please login to merge, or discard this patch.
neon/firefly/services/driveManager/interfaces/IFileSystem.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @throws \InvalidArgumentException if the $contents is an object and it does not have a getRealPath function
166 166
 	 * @return bool  True on success, false on failure.
167 167
 	 */
168
-	public function put($path, $contents, $visibility=null);
168
+	public function put($path, $contents, $visibility = null);
169 169
 
170 170
 	/**
171 171
 	 * Get meta data for this file
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @param  string  $algorithm  - Any algorithm supported by hash()
236 236
 	 * @return string  return the hash output string on success or an empty string if the file path can not be read as a stream
237 237
 	 */
238
-	public function hash($path, $algorithm='md5');
238
+	public function hash($path, $algorithm = 'md5');
239 239
 
240 240
 	/**
241 241
 	 * Get the underlying Flysystem driver
Please login to merge, or discard this patch.
neon/firefly/services/fileManager/models/FileManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
 	 * @param string $uuid
103 103
 	 * @return FileManager|null
104 104
 	 */
105
-	public static function get($uuid, $throwNotFoundExcaption=true)
105
+	public static function get($uuid, $throwNotFoundExcaption = true)
106 106
 	{
107 107
 		$model = neon()->cache->getOrSet($uuid, static function() use ($uuid) {
108 108
 			return static::findOne($uuid);
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,8 +107,9 @@
 block discarded – undo
107 107
 		$model = neon()->cache->getOrSet($uuid, static function() use ($uuid) {
108 108
 			return static::findOne($uuid);
109 109
 		});
110
-		if ($model === null && $throwNotFoundExcaption)
111
-			throw new FileNotFoundException("No file with id '$uuid' exists.");
110
+		if ($model === null && $throwNotFoundExcaption) {
111
+					throw new FileNotFoundException("No file with id '$uuid' exists.");
112
+		}
112 113
 		return $model;
113 114
 	}
114 115
 
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
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 *   'h' => height
135 135
 	 * @return string
136 136
 	 */
137
-	public function getImage($uuid, $params=[]);
137
+	public function getImage($uuid, $params = []);
138 138
 
139 139
 	/**
140 140
 	 * Get a file's visibility.
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 * - otherwise it will just return the value from the database
216 216
 	 * @return string|false - string the md5 checksum of the file contents, false on failure
217 217
 	 */
218
-	public function getFileHash($uuid, $refresh=false);
218
+	public function getFileHash($uuid, $refresh = false);
219 219
 
220 220
 	/**
221 221
 	 * Get the file size in bytes
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * If false will display the file in the browser
244 244
 	 * @return Response
245 245
 	 */
246
-	public function sendFile($uuid, $download=false);
246
+	public function sendFile($uuid, $download = false);
247 247
 
248 248
 	/**
249 249
 	 * Find a file manager file data by its drive and path location
Please login to merge, or discard this patch.
neon/firefly/services/mediaManager/models/Media.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param boolean $withDeleted
55 55
 	 * @return Media|null|\yii\db\ActiveRecord
56 56
 	 */
57
-	public static function findDirectoryByPath($path, $withDeleted=false)
57
+	public static function findDirectoryByPath($path, $withDeleted = false)
58 58
 	{
59 59
 		$path = static::getPath($path);
60 60
 		return static::query($withDeleted)
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param string $parentPath - the parent path used to find the parent node
88 88
 	 * @return Media|null|\yii\db\ActiveRecord
89 89
 	 */
90
-	public static function findParentByPath($path, &$parentPath='')
90
+	public static function findParentByPath($path, &$parentPath = '')
91 91
 	{
92 92
 		$info = pathinfo($path);
93 93
 		$parentPath = $info['dirname'];
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$node = new static(['path' => $path, 'type' => 'dir', 'parent_id' => $parent->id]);
112 112
 		$node->save();
113 113
 		if ($node->hasErrors()) {
114
-			throw new \Exception('Model validation errors: ' . print_r($node->getErrors(), true));
114
+			throw new \Exception('Model validation errors: '.print_r($node->getErrors(), true));
115 115
 		}
116 116
 		return $node->toArray();
117 117
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return array|Media[]
123 123
 	 */
124
-	public function getChildren($withDeleted=false)
124
+	public function getChildren($withDeleted = false)
125 125
 	{
126 126
 		return $this->getChildrenQuery($withDeleted)
127 127
 			->all();
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		if ($this->isDir()) {
237 237
 			//$this->updateChildPaths();
238 238
 			$originalPath = $this->path;
239
-			$newPath = str_replace('//', '/', $intoNode->path .'/'.basename($this->path));
239
+			$newPath = str_replace('//', '/', $intoNode->path.'/'.basename($this->path));
240 240
 			$this->path = $newPath;
241 241
 			$save = $this->save();
242 242
 			if ($save) {
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	public function updateChildPaths()
258 258
 	{
259 259
 		$this->updatePath();
260
-		foreach($this->getChildren(true) as $child)
260
+		foreach ($this->getChildren(true) as $child)
261 261
 			$child->updateChildPaths();
262 262
 	}
263 263
 
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 	public function rebuildPath()
278 278
 	{
279 279
 		$path = collect($this->getAncestors())->prepend($this)
280
-			->map(function($item){ return ($item->type === MEDIA::TYPE_DIR) ? basename($item->path) : ''; })
280
+			->map(function($item) { return ($item->type === MEDIA::TYPE_DIR) ? basename($item->path) : ''; })
281 281
 			->reverse()
282 282
 			->implode('/');
283 283
 		// allow for root node
284
-		$path = ($path==='') ? '/' : $path;
284
+		$path = ($path === '') ? '/' : $path;
285 285
 		// prevent trailing slash on files
286 286
 		return rtrim($path, '/');
287 287
 	}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	public static function replacePaths($findPath, $replacePath, $wherePath)
323 323
 	{
324 324
 		$tableName = static::tableName();
325
-		$sql = 'UPDATE ' . $tableName . ' SET path = REPLACE(path, :findPath, :replacePath) WHERE path LIKE :wherePath';
325
+		$sql = 'UPDATE '.$tableName.' SET path = REPLACE(path, :findPath, :replacePath) WHERE path LIKE :wherePath';
326 326
 		return Media::getDb()->createCommand($sql)
327 327
 			->bindValues([
328 328
 				':findPath' => $findPath,
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 *
338 338
 	 * @return \neon\core\db\ActiveQuery
339 339
 	 */
340
-	public function getChildrenQuery($withDeleted=false)
340
+	public function getChildrenQuery($withDeleted = false)
341 341
 	{
342 342
 		return static::query($withDeleted)
343 343
 			->where(['parent_id' => $this->id]);
Please login to merge, or discard this patch.
Braces   +21 added lines, -13 removed lines patch added patch discarded remove patch
@@ -106,8 +106,9 @@  discard block
 block discarded – undo
106 106
 	public static function createDirectory($path)
107 107
 	{
108 108
 		$parent = static::findParentByPath($path, $parentPath);
109
-		if ($parent === null)
110
-			throw new \Exception("Directory does not exist with path '$parentPath'");
109
+		if ($parent === null) {
110
+					throw new \Exception("Directory does not exist with path '$parentPath'");
111
+		}
111 112
 		$node = new static(['path' => $path, 'type' => 'dir', 'parent_id' => $parent->id]);
112 113
 		$node->save();
113 114
 		if ($node->hasErrors()) {
@@ -157,11 +158,13 @@  discard block
 block discarded – undo
157 158
 	{
158 159
 		$path = $this->$attribute;
159 160
 		// must be absolute and start with /
160
-		if ($path[0] !== '/')
161
-			$this->addError('path', "Must be absolute path and start with a '/' provided: '$path'");
161
+		if ($path[0] !== '/') {
162
+					$this->addError('path', "Must be absolute path and start with a '/' provided: '$path'");
163
+		}
162 164
 		// prevent folders with no names being created
163
-		if (strpos($path, '//') !== false)
164
-			$this->addError('path', "Path can not contain a double forward slash");
165
+		if (strpos($path, '//') !== false) {
166
+					$this->addError('path', "Path can not contain a double forward slash");
167
+		}
165 168
 	}
166 169
 
167 170
 	/**
@@ -216,11 +219,12 @@  discard block
 block discarded – undo
216 219
 	public function  moveInto(Media $intoNode)
217 220
 	{
218 221
 		// We must ensure we are not moving the item into itself!
219
-		if ($intoNode->id === $this->id)
220
-			return [
222
+		if ($intoNode->id === $this->id) {
223
+					return [
221 224
 				'success' => false,
222 225
 				'error' => 'Can not move an item inside itself'
223 226
 			];
227
+		}
224 228
 		// update the parentlatest version
225 229
 		$this->parent_id = $intoNode->id;
226 230
 		$success = false;
@@ -257,8 +261,9 @@  discard block
 block discarded – undo
257 261
 	public function updateChildPaths()
258 262
 	{
259 263
 		$this->updatePath();
260
-		foreach($this->getChildren(true) as $child)
261
-			$child->updateChildPaths();
264
+		foreach($this->getChildren(true) as $child) {
265
+					$child->updateChildPaths();
266
+		}
262 267
 	}
263 268
 
264 269
 	/**
@@ -295,7 +300,9 @@  discard block
 block discarded – undo
295 300
 		$parents = [];
296 301
 		do {
297 302
 			$item = $item->getParent();
298
-			if ($item) $parents[] = $item;
303
+			if ($item) {
304
+				$parents[] = $item;
305
+			}
299 306
 		} while ($item !== null);
300 307
 		return $parents;
301 308
 	}
@@ -380,8 +387,9 @@  discard block
 block discarded – undo
380 387
 	 */
381 388
 	public static function getPath($path)
382 389
 	{
383
-		if ($path === '/' && neon()->firefly->mediaManager->getRootPath() !== '/')
384
-			$path = neon()->firefly->mediaManager->getRootPath();
390
+		if ($path === '/' && neon()->firefly->mediaManager->getRootPath() !== '/') {
391
+					$path = neon()->firefly->mediaManager->getRootPath();
392
+		}
385 393
 		return $path;
386 394
 	}
387 395
 
Please login to merge, or discard this patch.
neon/firefly/services/MediaManager.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		$bits = explode('/', $path);
77 77
 		$bitsCurrent = [];
78 78
 		$parts = [];
79
-		foreach($bits as $i => $bit) {
79
+		foreach ($bits as $i => $bit) {
80 80
 			$bitsCurrent[] = $bit;
81 81
 			if ($i == 0) continue;
82 82
 			$parts[] = implode('/', $bitsCurrent);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @param array $filters - array of additional search filters passed to Query where clause
119 119
 	 * @return array|\yii\db\ActiveRecord[]
120 120
 	 */
121
-	private function _listQuery($directory = '', $withDeleted=false, $filters=[])
121
+	private function _listQuery($directory = '', $withDeleted = false, $filters = [])
122 122
 	{
123 123
 		$directory = $this->getRealPath($directory);
124 124
 		$item = Media::findDirectoryByPath($directory, $withDeleted);
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
 		return collect($items)->map(function($item) use ($filesIndex) {
144 144
 			$file = $filesIndex->get($item['id']);
145
-			$item['concatName'] = $item['path'] .'/'. ($file ? $file['name'] : '');
145
+			$item['concatName'] = $item['path'].'/'.($file ? $file['name'] : '');
146 146
 			$item['file'] = $file;
147 147
 			$item['path'] = Media::formatPath($item['path']);
148 148
 			return $item;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	/**
153 153
 	 * @inheritDoc
154 154
 	 */
155
-	public function listContents($directory = '', $withDeleted=false)
155
+	public function listContents($directory = '', $withDeleted = false)
156 156
 	{
157 157
 		return $this->_listQuery($directory, $withDeleted);
158 158
 	}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		$items = $query->all();
174 174
 
175 175
 
176
-		foreach($items as $key => $item) {
176
+		foreach ($items as $key => $item) {
177 177
 			$items[$key]['path'] = Media::formatPath($item['path']);
178 178
 		}
179 179
 		return $items;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	/**
183 183
 	 * @inheritDoc
184 184
 	 */
185
-	public function addFile($id, $path='/')
185
+	public function addFile($id, $path = '/')
186 186
 	{
187 187
 		// Find the file
188 188
 		$fileMeta = neon()->firefly->getMeta($id);
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 
256 256
 
257 257
 		// make sure it does not already exist
258
-		if (! empty(Media::findDirectoryByPath($newPath))) {
258
+		if (!empty(Media::findDirectoryByPath($newPath))) {
259 259
 			throw new DirectoryExistsException("The directory '$newPath' already exists");
260 260
 		}
261 261
 		$node->path = $newPath;
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 */
289 289
 	public function setRootPath($path)
290 290
 	{
291
-		$this->_rootPath = rtrim($path, '/') . '/';
291
+		$this->_rootPath = rtrim($path, '/').'/';
292 292
 	}
293 293
 
294 294
 	/**
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 			->where(['deleted' => 1])
354 354
 			->all();
355 355
 		$destroyed = [];
356
-		foreach($items as $item) {
356
+		foreach ($items as $item) {
357 357
 			$destroyed[$item->id] = $item->destroy();
358 358
 		}
359 359
 		return $destroyed;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 		$items = Media::findAll(['id' => $items]);
379 379
 		// update each item
380 380
 		$success = [];
381
-		foreach($items as $item) {
381
+		foreach ($items as $item) {
382 382
 			$success[$item->id] = $item->moveInto($into);
383 383
 		}
384 384
 		return $success;
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	 */
395 395
 	public function getRealPath($path)
396 396
 	{
397
-		$path = $this->getRootPath() . ltrim($path, '/');
397
+		$path = $this->getRootPath().ltrim($path, '/');
398 398
 		return strlen($path) === 1 ? '/' : rtrim($path, '/');
399 399
 	}
400 400
 }
Please login to merge, or discard this patch.
Braces   +44 added lines, -26 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 		}, $paths);
49 49
 
50 50
 		if (empty($created)) {
51
-			if ($directory == '')
52
-				throw new DirectoryExistsException("The root directory already exists");
51
+			if ($directory == '') {
52
+							throw new DirectoryExistsException("The root directory already exists");
53
+			}
53 54
 			throw new DirectoryExistsException("The directory '$directory' already exists");
54 55
 		}
55 56
 		return $created;
@@ -78,7 +79,9 @@  discard block
 block discarded – undo
78 79
 		$parts = [];
79 80
 		foreach($bits as $i => $bit) {
80 81
 			$bitsCurrent[] = $bit;
81
-			if ($i == 0) continue;
82
+			if ($i == 0) {
83
+				continue;
84
+			}
82 85
 			$parts[] = implode('/', $bitsCurrent);
83 86
 		}
84 87
 		return $parts;
@@ -91,14 +94,17 @@  discard block
 block discarded – undo
91 94
 	 */
92 95
 	public function validateAbsoluteDirectoryPath($directory)
93 96
 	{
94
-		if (!is_string($directory))
95
-			throw new InvalidDirectoryException("Invalid directory parameter '$directory'. The directory must be absolute string path and start with '/'.");
97
+		if (!is_string($directory)) {
98
+					throw new InvalidDirectoryException("Invalid directory parameter '$directory'. The directory must be absolute string path and start with '/'.");
99
+		}
96 100
 		// must be absolute and start with /
97
-		if ($directory[0] !== '/')
98
-			throw new InvalidDirectoryException("Invalid directory parameter '$directory'. The directory must be absolute path and start with '/'.");
101
+		if ($directory[0] !== '/') {
102
+					throw new InvalidDirectoryException("Invalid directory parameter '$directory'. The directory must be absolute path and start with '/'.");
103
+		}
99 104
 		// prevent folders with no names being created
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.");
105
+		if (strpos($directory, '//') !== false) {
106
+					throw new InvalidDirectoryException("Invalid directory parameter '$directory'. You can not have empty path sections containing '//' each directory needs a name.");
107
+		}
102 108
 	}
103 109
 
104 110
 	/**
@@ -123,7 +129,9 @@  discard block
 block discarded – undo
123 129
 		$directory = $this->getRealPath($directory);
124 130
 		$item = Media::findDirectoryByPath($directory, $withDeleted);
125 131
 
126
-		if (empty($item)) return [];
132
+		if (empty($item)) {
133
+			return [];
134
+		}
127 135
 
128 136
 		$m = Media::tableName();
129 137
 		$f = FileManager::tableName();
@@ -132,8 +140,9 @@  discard block
 block discarded – undo
132 140
 			->orderBy("type ASC, $m.path, $f.name ASC")
133 141
 			->leftJoin(FileManager::tableName(), "id = $f.uuid")
134 142
 			->asArray();
135
-		if (!empty($filters))
136
-			$query->where($filters);
143
+		if (!empty($filters)) {
144
+					$query->where($filters);
145
+		}
137 146
 		$items = $query->all();
138 147
 
139 148
 		$ids = collect($items)->pluck('id');
@@ -218,10 +227,11 @@  discard block
 block discarded – undo
218 227
 			throw new BadRequestHttpException('A name cannot contain a "/" character');
219 228
 		}
220 229
 
221
-		if ($node->isDir())
222
-			$this->_updateDirectoryName($node, $name);
223
-		else
224
-			$this->_updateFileName($node, $name);
230
+		if ($node->isDir()) {
231
+					$this->_updateDirectoryName($node, $name);
232
+		} else {
233
+					$this->_updateFileName($node, $name);
234
+		}
225 235
 		return true;
226 236
 	}
227 237
 
@@ -297,7 +307,9 @@  discard block
 block discarded – undo
297 307
 	public function getDirectoryMeta($path)
298 308
 	{
299 309
 		$dir = Media::findDirectoryByPath($path);
300
-		if ($dir === null) return [];
310
+		if ($dir === null) {
311
+			return [];
312
+		}
301 313
 		return $dir->toArray();
302 314
 	}
303 315
 
@@ -307,7 +319,9 @@  discard block
 block discarded – undo
307 319
 	public function getMeta($id)
308 320
 	{
309 321
 		$item = Media::find()->where(['id' => $id])->asArray()->one();
310
-		if ($item === null) return [];
322
+		if ($item === null) {
323
+			return [];
324
+		}
311 325
 		if ($item['type'] === 'file') {
312 326
 			$item['file'] = neon()->firefly->fileManager->getMeta($id);
313 327
 		}
@@ -320,8 +334,9 @@  discard block
 block discarded – undo
320 334
 	public function delete($id)
321 335
 	{
322 336
 		$item = Media::findOne($id);
323
-		if ($item === null)
324
-			throw new NotFoundHttpException("No item with id '$id' could be found'");
337
+		if ($item === null) {
338
+					throw new NotFoundHttpException("No item with id '$id' could be found'");
339
+		}
325 340
 		$result = $item->delete();
326 341
 		if ($result === false) {
327 342
 			return $item->getErrors();
@@ -335,8 +350,9 @@  discard block
 block discarded – undo
335 350
 	public function destroy($id)
336 351
 	{
337 352
 		$item = Media::findWithDeleted()->where(['id' => $id])->one();
338
-		if ($item === null)
339
-			throw new NotFoundHttpException("No item with id '$id' could be found'");
353
+		if ($item === null) {
354
+					throw new NotFoundHttpException("No item with id '$id' could be found'");
355
+		}
340 356
 		return $item->destroy();
341 357
 	}
342 358
 
@@ -368,11 +384,13 @@  discard block
 block discarded – undo
368 384
 		$into = Media::findOne($intoId);
369 385
 
370 386
 		// throw error if it doesn't exist
371
-		if ($into === null)
372
-			throw new NotFoundHttpException("No item with id '$intoId' could be found'");
387
+		if ($into === null) {
388
+					throw new NotFoundHttpException("No item with id '$intoId' could be found'");
389
+		}
373 390
 		// throw error if its not a directory
374
-		if (!$into->isDir())
375
-			throw new BadRequestHttpException("This is not a directory - you can only move items into directories");
391
+		if (!$into->isDir()) {
392
+					throw new BadRequestHttpException("This is not a directory - you can only move items into directories");
393
+		}
376 394
 
377 395
 		// find all items to move
378 396
 		$items = Media::findAll(['id' => $items]);
Please login to merge, or discard this patch.