1 | <?php |
||
7 | trait DateTraits |
||
8 | { |
||
9 | // Regular Expression for the date: |
||
10 | private $dateRegExp = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/'; |
||
11 | |||
12 | // Date from which to request historic rates: |
||
13 | private $dateFrom; |
||
14 | |||
15 | // Date to which to request historic rates: |
||
16 | private $dateTo; |
||
17 | |||
18 | // Get the "from" date: |
||
19 | public function getDateFrom() |
||
23 | |||
24 | // Get the "to" date: |
||
25 | public function getDateTo() |
||
29 | |||
30 | // Add a date-from: |
||
31 | public function addDateFrom(string $from) |
||
42 | |||
43 | // Add a date-to: |
||
44 | public function addDateTo(string $to) |
||
55 | |||
56 | // Validate a date is in the correct format: |
||
57 | private function validateDateFormat(string $date = null) |
||
65 | } |
||
66 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: