Passed
Push — develop ( ecbe19...f5d3ab )
by Jens
02:58
created

DocumentFolderComponent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 38
rs 10
wmc 4
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 8 1
A checkParameters() 0 10 3
1
<?php
2
/**
3
 * Created by jensk on 17-3-2017.
4
 */
5
6
namespace library\components;
7
8
9
use library\storage\Storage;
10
11
class DocumentFolderComponent extends BaseComponent
12
{
13
	const PARAMETER_DOCUMENT_FOLDER_PATH = 'documentFolderPath';
14
	const PARAMETER_DOCUMENT_FOLDER_PARAMETER_NAME = 'documentFolderParameter';
15
16
	protected $documentFolderParameterName = 'folder';
17
	protected $documentFolderPath;
18
19
	/**
20
	 * @param Storage $storage
21
	 *
22
	 * @return mixed|void
23
	 * @throws \Exception
24
	 */
25
	public function run(Storage $storage)
26
	{
27
		parent::run($storage);
28
29
		$this->checkParameters();
30
31
		$this->parameters[$this->documentFolderParameterName] = $this->storage->getDocumentFolderBySlug($this->documentFolderPath);
32
	}
33
34
35
	/**
36
	 * Checks to see if any parameters were defined in the cms and acts according
37
	 */
38
	private function checkParameters()
39
	{
40
		if (isset($this->parameters[self::PARAMETER_DOCUMENT_FOLDER_PATH])) {
41
			$this->documentFolderPath = $this->parameters[self::PARAMETER_DOCUMENT_FOLDER_PATH];
42
		}
43
44
		if (isset($this->parameters[self::PARAMETER_DOCUMENT_FOLDER_PARAMETER_NAME])) {
45
			$this->documentFolderParameterName = $this->parameters[self::PARAMETER_DOCUMENT_FOLDER_PARAMETER_NAME];
46
		}
47
	}
48
}