Completed
Pull Request — master (#467)
by
unknown
16:58
created

GanttTask::getStartDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * File holding the GanttTask class
4
 *
5
 * Creates Tasks with params
6
 *
7
 * @author Sebastian Schmid
8
 * @file
9
 * @ingroup SemanticResultFormats
10
 */
11
12
namespace SRF\Gantt;
13
14
15
class GanttTask {
16
17
	private $mTitle;
18
	private $mID;
19
	private $mStatus = "";
20
	private $mPriority = "";
21
	private $mStartDate;
22
	private $mEndDate;
23
24
25
	public function setTitle( $title ) {
26
		$this->mTitle = $title;
27
	}
28
29
	public function getTitle() {
30
		return $this->mTitle;
31
	}
32
33
	public function setID( $id ) {
34
		$this->mID = $id;
35
	}
36
37
	public function getID() {
38
		return $this->mID;
39
	}
40
41
	public function setStatus($status){
42
		$this->mStatus = $this->mStatus . $status . ', ';
43
	}
44
45
	public function setPriority($priority){
46
		$this->mPriority = $this->mPriority . $priority . ', ';
47
	}
48
49
	/**
50
	 * Either set the status or priority of the task
51
	 *
52
	 * @param array $params
53
	 * @param string $paramMapping
54
	 * @param string $type
55
	 *
56
	 */
57
	public function setTaskParam( $params, $paramMapping, $type ) {
58
59
		// skip if $paramMapping is empty and
60
		// output errormessage if wrong mapping
61
		if ( !empty( $paramMapping ) ) {
62
63
			$paramMapping = explode( ';', $paramMapping );
64
			$mapping = [];
65
66
			foreach ( $paramMapping as $pm ) {
67
				$pmKeyVal = explode( '=>', $pm );
68
				$mapping[trim($pmKeyVal[0])] = trim($pmKeyVal[1]);
69
			}
70
71
			//validate Params
72
			foreach ( $mapping as $mappedValue => $realParam ) {
73
				if ( in_array( $mappedValue, $params ) ) {
74
					if ( $type == "status" ) {
75
						$this->setStatus($realParam);
76
					} else {
77
						if ( $type == "priority" ) {
78
							$this->setPriority($realParam);
79
						}
80
					}
81
				}
82
			}
83
84
		}
85
	}
86
87
	public function getStatus() {
88
		return $this->mStatus;
89
	}
90
91
	public function getPriority() {
92
		return $this->mPriority;
93
	}
94
95
	public function setStartDate( $startDate ) {
96
		$this->mStartDate = $startDate;
97
	}
98
99
	public function getStartDate() {
100
		return $this->mStartDate;
101
	}
102
103
	public function setEndDate( $endDate ) {
104
		$this->mEndDate = $endDate;
105
	}
106
107
	public function getEndDate() {
108
		return $this->mEndDate;
109
	}
110
}