1 | <?php |
||
10 | class Sprint |
||
11 | { |
||
12 | use DateHelper; |
||
13 | /** |
||
14 | * @var \DateTime |
||
15 | */ |
||
16 | private $start; |
||
17 | |||
18 | /** |
||
19 | * @var \DateInterval |
||
20 | */ |
||
21 | private $duration; |
||
22 | |||
23 | /** |
||
24 | * @const String |
||
25 | */ |
||
26 | const INTERVAL = 'P1D'; |
||
27 | |||
28 | /** |
||
29 | * @return \DateTime |
||
30 | */ |
||
31 | 3 | public function getStart() |
|
35 | |||
36 | /** |
||
37 | * @return \DateInterval |
||
38 | */ |
||
39 | 1 | public function getDuration() |
|
43 | |||
44 | /** |
||
45 | * @param \DateTime $start |
||
46 | */ |
||
47 | 8 | public function setStart(\DateTime $start) |
|
51 | |||
52 | /** |
||
53 | * @param \DateInterval $duration |
||
54 | */ |
||
55 | 8 | public function setDuration(\DateInterval $duration) |
|
59 | |||
60 | /** |
||
61 | * Calculate the end of sprint from start and duration. |
||
62 | * |
||
63 | * @return \DateTime|null |
||
64 | */ |
||
65 | 4 | public function getEnd() |
|
75 | |||
76 | /** |
||
77 | * Get all days in the sprint from start date |
||
78 | * and during duration. |
||
79 | * |
||
80 | * @return \DatePeriod|null |
||
81 | */ |
||
82 | 3 | public function getSprintDays() |
|
100 | |||
101 | /** |
||
102 | * Calculate the next day in the sprint. |
||
103 | * |
||
104 | * @return \DateTime |
||
105 | */ |
||
106 | 1 | public function getNextDayInSprint() |
|
107 | { |
||
108 | 1 | $today = new \DateTime(); |
|
109 | 1 | $today->setTime(0, 0, 0); |
|
110 | |||
111 | 1 | if ($today->format('N') == 5) { |
|
112 | 1 | return $today->modify('+3 days'); |
|
113 | } |
||
114 | |||
115 | if ($today->format('N') == 6) { |
||
116 | return $today->modify('+2 days'); |
||
117 | } |
||
118 | |||
119 | return $today->modify('+1 days'); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * Calculate the total work days in the sprint. |
||
124 | * This function does not return week-end days but |
||
125 | * return non-work-days such as christmas. |
||
126 | * |
||
127 | * @return null|int |
||
128 | */ |
||
129 | 1 | public function getTotalWorkDays() |
|
147 | } |
||
148 |