@@ -26,56 +26,56 @@ discard block |
||
26 | 26 | const ERROR_NO_DATE_FROM_SET = 43401; |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @var int |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var int |
|
31 | + */ |
|
32 | 32 | protected $dateFrom; |
33 | 33 | |
34 | - /** |
|
35 | - * @var int |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var int |
|
36 | + */ |
|
37 | 37 | protected $dateTo; |
38 | 38 | |
39 | - /** |
|
40 | - * @var bool |
|
41 | - */ |
|
39 | + /** |
|
40 | + * @var bool |
|
41 | + */ |
|
42 | 42 | protected $future = false; |
43 | 43 | |
44 | - /** |
|
45 | - * @var string |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @var string |
|
46 | + */ |
|
47 | 47 | protected $interval = ''; |
48 | 48 | |
49 | - /** |
|
50 | - * @var int |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var int |
|
51 | + */ |
|
52 | 52 | protected $difference = 0; |
53 | 53 | |
54 | - /** |
|
55 | - * @var int |
|
56 | - */ |
|
54 | + /** |
|
55 | + * @var int |
|
56 | + */ |
|
57 | 57 | protected $dateDiff = 0; |
58 | 58 | |
59 | - /** |
|
60 | - * @var array |
|
61 | - */ |
|
59 | + /** |
|
60 | + * @var array |
|
61 | + */ |
|
62 | 62 | protected static $texts; |
63 | 63 | |
64 | 64 | public function __construct() |
65 | 65 | { |
66 | 66 | } |
67 | 67 | |
68 | - /** |
|
69 | - * Sets the origin date to calculate from. |
|
70 | - * |
|
71 | - * NOTE: if this is further in the future than |
|
72 | - * the to: date, it will be considered as a |
|
73 | - * calculation for something to come, i.e. |
|
74 | - * "In two days". |
|
75 | - * |
|
76 | - * @param \DateTime $date |
|
77 | - * @return ConvertHelper_DurationConverter |
|
78 | - */ |
|
68 | + /** |
|
69 | + * Sets the origin date to calculate from. |
|
70 | + * |
|
71 | + * NOTE: if this is further in the future than |
|
72 | + * the to: date, it will be considered as a |
|
73 | + * calculation for something to come, i.e. |
|
74 | + * "In two days". |
|
75 | + * |
|
76 | + * @param \DateTime $date |
|
77 | + * @return ConvertHelper_DurationConverter |
|
78 | + */ |
|
79 | 79 | public function setDateFrom(\DateTime $date) : ConvertHelper_DurationConverter |
80 | 80 | { |
81 | 81 | $this->dateFrom = ConvertHelper::date2timestamp($date); |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | return $this; |
84 | 84 | } |
85 | 85 | |
86 | - /** |
|
87 | - * Sets the date to calculate to. Defaults to |
|
88 | - * the current time if not set. |
|
89 | - * |
|
90 | - * @param \DateTime $date |
|
91 | - * @return ConvertHelper_DurationConverter |
|
92 | - */ |
|
86 | + /** |
|
87 | + * Sets the date to calculate to. Defaults to |
|
88 | + * the current time if not set. |
|
89 | + * |
|
90 | + * @param \DateTime $date |
|
91 | + * @return ConvertHelper_DurationConverter |
|
92 | + */ |
|
93 | 93 | public function setDateTo(\DateTime $date) : ConvertHelper_DurationConverter |
94 | 94 | { |
95 | 95 | $this->dateTo = ConvertHelper::date2timestamp($date); |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | return $this; |
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * Converts the specified dates to a human readable string. |
|
102 | - * |
|
103 | - * @throws ConvertHelper_Exception |
|
104 | - * @return string |
|
105 | - * |
|
106 | - * @see ConvertHelper_DurationConverter::ERROR_NO_DATE_FROM_SET |
|
107 | - */ |
|
100 | + /** |
|
101 | + * Converts the specified dates to a human readable string. |
|
102 | + * |
|
103 | + * @throws ConvertHelper_Exception |
|
104 | + * @return string |
|
105 | + * |
|
106 | + * @see ConvertHelper_DurationConverter::ERROR_NO_DATE_FROM_SET |
|
107 | + */ |
|
108 | 108 | public function convert() : string |
109 | 109 | { |
110 | 110 | $this->initTexts(); |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | |
113 | 113 | $epoch = 'past'; |
114 | 114 | $key = 'singular'; |
115 | - if($this->dateDiff > 1) { |
|
115 | + if ($this->dateDiff > 1) { |
|
116 | 116 | $key = 'plural'; |
117 | 117 | } |
118 | 118 | |
119 | - if($this->future) { |
|
119 | + if ($this->future) { |
|
120 | 120 | $epoch = 'future'; |
121 | 121 | } |
122 | 122 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | protected function initTexts() |
131 | 131 | { |
132 | - if(isset(self::$texts)) { |
|
132 | + if (isset(self::$texts)) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $day = (int)date("j", $this->dateTo); |
216 | 216 | $year = (int)date("Y", $this->dateFrom); |
217 | 217 | |
218 | - while(mktime($hour, $min, $sec, $month + ($months_difference), $day, $year) < $this->dateTo) |
|
218 | + while (mktime($hour, $min, $sec, $month + ($months_difference), $day, $year) < $this->dateTo) |
|
219 | 219 | { |
220 | 220 | $months_difference++; |
221 | 221 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | protected function resolveCalculations() : void |
237 | 237 | { |
238 | - if(!isset($this->dateFrom)) |
|
238 | + if (!isset($this->dateFrom)) |
|
239 | 239 | { |
240 | 240 | throw new ConvertHelper_Exception( |
241 | 241 | 'No date from has been specified.', |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | // no date to set? Assume we want to use today. |
248 | - if(!isset($this->dateTo)) |
|
248 | + if (!isset($this->dateTo)) |
|
249 | 249 | { |
250 | 250 | $this->dateTo = time(); |
251 | 251 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | |
325 | 325 | $difference = $this->dateTo - $this->dateFrom; |
326 | 326 | |
327 | - if($difference < 0) |
|
327 | + if ($difference < 0) |
|
328 | 328 | { |
329 | 329 | $difference = $difference * -1; |
330 | 330 | $this->future = true; |