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