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

ImageSetFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createImageSetFromPostValues() 0 16 2
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
}