|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Abstract Valuator |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Roomify\Bat\Valuator; |
|
9
|
|
|
|
|
10
|
|
|
use Roomify\Bat\Valuator\ValuatorInterface; |
|
11
|
|
|
use Roomify\Bat\Unit\Unit; |
|
12
|
|
|
|
|
13
|
|
|
abstract class AbstractValuator implements ValuatorInterface { |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* The start date of the period over which we should reason about value |
|
17
|
|
|
* |
|
18
|
|
|
* @var /DateTime |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $start_date; |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* The end date of the period over which we should reason about value |
|
25
|
|
|
* @var /DateTime |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $end_date; |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* The unit involved |
|
32
|
|
|
* @var |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $unit; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* AbstractValuator constructor. |
|
38
|
|
|
* @param \DateTime $start_date |
|
39
|
|
|
* @param \DateTime $end_date |
|
40
|
|
|
* @param \Roomify\Bat\Unit\Unit $unit |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct(\DateTime $start_date, \DateTime $end_date, Unit $unit) { |
|
43
|
|
|
$this->start_date = clone($start_date); |
|
44
|
|
|
$this->end_date = clone($end_date); |
|
45
|
|
|
$this->unit = $unit; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param \DateTime $start_date |
|
50
|
|
|
*/ |
|
51
|
|
|
public function setStartDate(\DateTime $start_date) { |
|
52
|
|
|
$this->start_date = clone($start_date); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return \DateTime |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getStartDate() { |
|
59
|
|
|
return $this->start_date; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param \DateTime $end_date |
|
64
|
|
|
*/ |
|
65
|
|
|
public function setEndDate(\DateTime $end_date) { |
|
66
|
|
|
$this->end_date = $end_date; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param \DateTime $end_date |
|
71
|
|
|
* @return \DateTime |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getEndDate(\DateTime $end_date) { |
|
|
|
|
|
|
74
|
|
|
return $this->end_date; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param \Roomify\Bat\Unit\Unit $unit |
|
79
|
|
|
*/ |
|
80
|
|
|
public function setUnit(Unit $unit) { |
|
81
|
|
|
$this->unit = $unit; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return \Roomify\Bat\Unit\Unit |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getUnit() { |
|
88
|
|
|
return $this->unit; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @param $events |
|
93
|
|
|
* @return mixed |
|
94
|
|
|
*/ |
|
95
|
|
|
public abstract function determineValue($events); |
|
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
} |
|
98
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.