Total Complexity | 15 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class Date implements \Validate\Contracts\Validate |
||
8 | { |
||
9 | public static function toDatabase($dataOriginal) |
||
10 | { |
||
11 | $data = explode('/', $dataOriginal); |
||
12 | if (isset($data[2])) { |
||
13 | if($data[1]>12) { |
||
14 | return $data[2] .'-'. $data[0] .'-'. $data[1]; |
||
15 | } |
||
16 | return $data[2] .'-'. $data[1] .'-'. $data[0]; |
||
17 | } |
||
18 | return $dataOriginal; |
||
19 | } |
||
20 | |||
21 | public static function toUser($data) |
||
22 | { |
||
23 | return $data; |
||
24 | } |
||
25 | |||
26 | public static function validate($dataOriginal) |
||
33 | } |
||
34 | |||
35 | |||
36 | public static function validateYear($year) |
||
37 | { |
||
38 | return true; |
||
39 | } |
||
40 | |||
41 | public static function validateYearPresentOrFuturo($year) |
||
42 | { |
||
43 | return true; |
||
44 | } |
||
45 | |||
46 | public static function validateMonth($month) |
||
47 | { |
||
48 | $month = (int) $month; |
||
49 | if ($month>12) { |
||
50 | return false; |
||
51 | } |
||
52 | return true; |
||
53 | } |
||
54 | |||
55 | public static function yearToDatabase($year) |
||
56 | { |
||
57 | $year = (int) $year; |
||
58 | |||
59 | if ($year>99) { |
||
60 | return $year; |
||
61 | } |
||
62 | if ($year>50) { |
||
63 | return 1900+$year; |
||
64 | } |
||
65 | return 2000+$year; |
||
66 | } |
||
67 | |||
68 | public static function monthToDatabase($month) |
||
71 | } |
||
72 | |||
73 | public static function isSame(string $to, string $from) |
||
74 | { |
||
75 | return (self::toDatabase($to)===self::toDatabase($from)); |
||
76 | } |
||
77 | |||
78 | } |
||
79 |