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

DocumentFolderFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createDocumentFolderFromPostValues() 0 14 2
1
<?php
2
/**
3
 * User: jensk
4
 * Date: 13-3-2017
5
 * Time: 17:03
6
 */
7
8
namespace library\storage\factories;
9
10
11
class DocumentFolderFactory
12
{
13
	/**
14
	 * Create folder from post values
15
	 *
16
	 * @param $postValues
17
	 *
18
	 * @return \stdClass
19
	 * @throws \Exception
20
	 */
21
	public static function createDocumentFolderFromPostValues($postValues)
22
	{
23
		if (isset($postValues['title'], $postValues['path'], $postValues['content'])) {
24
			$documentFolderObject = new Document();
25
			$documentFolderObject->title = $postValues['title'];
26
			$documentFolderObject->slug = slugify($postValues['title']);
27
			$documentFolderObject->type = 'folder';
28
			$documentFolderObject->content = json_decode($postValues['content']);
29
30
			return $documentFolderObject;
31
		} else {
32
			throw new \Exception('Trying to create document folder with invalid data.');
33
		}
34
	}
35
}