Passed
Push — master ( 3f6c85...9c6499 )
by Jens
02:40
created

ImageSetFactory::createImageSetFromPostValues()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 1
dl 16
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * User: jensk
4
 * Date: 13-3-2017
5
 * Time: 17:05
6
 */
7
8
namespace library\storage\factories;
9
10
11
use library\cc\StringUtil;
12
13 View Code Duplication
class ImageSetFactory
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
	/**
16
	 * Ceate image set from post values
17
	 *
18
	 * @param $postValues
19
	 *
20
	 * @return \stdClass
21
	 * @throws \Exception
22
	 */
23
	public static function createImageSetFromPostValues($postValues)
24
	{
25
		if (isset($postValues['title'], $postValues['width'], $postValues['height'], $postValues['method'])) {
26
			$imageSetObject = new \stdClass();
27
28
			$imageSetObject->title = $postValues['title'];
29
			$imageSetObject->slug = StringUtil::slugify($postValues['title']);
30
			$imageSetObject->width = $postValues['width'];
31
			$imageSetObject->height = $postValues['height'];
32
			$imageSetObject->method = $postValues['method'];
33
34
			return $imageSetObject;
35
		} else {
36
			throw new \Exception('Trying to create image set with invalid data.');
37
		}
38
	}
39
}