Total Complexity | 15 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 5 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
8 | class ValidJalaliDate implements Rule |
||
9 | { |
||
10 | public function __construct( |
||
11 | public string $character = '/', |
||
12 | ) {} |
||
13 | |||
14 | /** |
||
15 | * Check jalali date is valid. |
||
16 | */ |
||
17 | public function passes($attribute, $value): bool |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Get the validation error message. |
||
34 | */ |
||
35 | public function message(): string |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Checking whether the date is a Jalali date or not. |
||
42 | */ |
||
43 | protected function checkValidDate(int $year, int $month, int $day): bool |
||
44 | { |
||
45 | return ($year >= -61 && $year <= 3177) |
||
46 | && ($month >= 1 && $month <= 12) |
||
47 | && $day >= 1 && $day <= $this->jalaliMonthLength($year, $month, $day); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Getting the number of days through the length of the month. |
||
52 | */ |
||
53 | protected function jalaliMonthLength(int $year, int $month, int $day): int |
||
63 | } |
||
64 | } |
||
65 |