Passed
Push — develop ( 44d21a...7d51f9 )
by Neill
34:25 queued 18:25
created
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.
neon/cms/services/cmsEditor/Parser.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 	 * @since 3.8.0
82 82
 	 *
83 83
 	 */
84
-	function __construct($name, $attrs, $innerBlocks, $innerHTML, $innerContent, $uuid=null)
84
+	function __construct($name, $attrs, $innerBlocks, $innerHTML, $innerContent, $uuid = null)
85 85
 	{
86 86
 		$this->cmp = $name;
87 87
 		$this->props = $attrs;
88 88
 		//$this->innerBlocks = $innerBlocks;
89 89
 		//$this->innerHTML = $innerHTML;
90 90
 		//$this->innerContent = $innerContent;
91
-		if (isset($attrs['uuid']) ) {
91
+		if (isset($attrs['uuid'])) {
92 92
 			$uuid = $attrs['uuid'];
93 93
 		}
94 94
 		$this->uuid = $uuid ? $uuid : Hash::uuid64();
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 				if (0 === $stack_depth) {
301 301
 					if (isset($leading_html_start)) {
302 302
 						$uuid = Hash::uuid64();
303
-						$this->output[$uuid] = (array)self::freeform(
303
+						$this->output[$uuid] = (array) self::freeform(
304 304
 							substr(
305 305
 								$this->document,
306 306
 								$leading_html_start,
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 							), $uuid
309 309
 						);
310 310
 					}
311
-					$cmp = (array)new Cmp($block_name, $attrs, array(), '', array(), $uuid);
311
+					$cmp = (array) new Cmp($block_name, $attrs, array(), '', array(), $uuid);
312 312
 					$this->output[$cmp->uuid] = $cmp;
313 313
 					$this->offset = $start_offset + $token_length;
314 314
 					return true;
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 		$is_void = isset($matches['void']) && -1 !== $matches['void'][1];
424 424
 		$namespace = $matches['namespace'];
425 425
 		$namespace = (isset($namespace) && -1 !== $namespace[1]) ? $namespace[0] : ''; // 'core/';
426
-		$name = $namespace . $matches['name'][0];
426
+		$name = $namespace.$matches['name'][0];
427 427
 		$has_attrs = isset($matches['attrs']) && -1 !== $matches['attrs'][1];
428 428
 		/*
429 429
 		 * Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 			return;
478 478
 		}
479 479
 		$uuid = Hash::uuid64();
480
-		$this->output[$uuid] = (array)self::freeform(substr($this->document, $this->offset, $length), $uuid);
480
+		$this->output[$uuid] = (array) self::freeform(substr($this->document, $this->offset, $length), $uuid);
481 481
 	}
482 482
 
483 483
 	/**
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 		}
527 527
 		if (isset($stack_top->leading_html_start)) {
528 528
 			$uuid = Hash::uuid64();
529
-			$this->output[$uuid] = (array)self::freeform(
529
+			$this->output[$uuid] = (array) self::freeform(
530 530
 				substr(
531 531
 					$this->document,
532 532
 					$stack_top->leading_html_start,
@@ -534,6 +534,6 @@  discard block
 block discarded – undo
534 534
 				), $uuid
535 535
 			);
536 536
 		}
537
-		$this->output[$stack_top->block->uuid] = (array)$stack_top->block;
537
+		$this->output[$stack_top->block->uuid] = (array) $stack_top->block;
538 538
 	}
539 539
 }
540 540
\ No newline at end of file
Please login to merge, or discard this patch.
neon/cms/services/CmpManager.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 
10 10
 class CmpManager extends \yii\base\Component
11 11
 {
12
-	public function getComponents(){
12
+	public function getComponents() {
13 13
 
14 14
 	}
15 15
 }
16 16
\ No newline at end of file
Please login to merge, or discard this patch.