Passed
Push — develop ( 87f23a...408180 )
by Jens
02:57
created

ImageSetFactory::createImageSetFromPostValues()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 1
dl 0
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
class ImageSetFactory
12
{
13
	/**
14
	 * Ceate image set from post values
15
	 *
16
	 * @param $postValues
17
	 *
18
	 * @return \stdClass
19
	 * @throws \Exception
20
	 */
21
	public static function createImageSetFromPostValues($postValues)
22
	{
23
		if (isset($postValues['title'], $postValues['width'], $postValues['height'], $postValues['method'])) {
24
			$imageSetObject = new \stdClass();
25
26
			$imageSetObject->title = $postValues['title'];
27
			$imageSetObject->slug = slugify($postValues['title']);
28
			$imageSetObject->width = $postValues['width'];
29
			$imageSetObject->height = $postValues['height'];
30
			$imageSetObject->method = $postValues['method'];
31
32
			return $imageSetObject;
33
		} else {
34
			throw new \Exception('Trying to create image set with invalid data.');
35
		}
36
	}
37
}