Skip to content

Commit

Permalink
Convert switch to match
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Oct 17, 2023
1 parent 8fcf8d5 commit e758646
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/Field/MonthOfYear.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,11 @@ public static function check(int $monthOfYear): void
*/
public static function getLength(int $monthOfYear, ?int $year = null): int
{
switch ($monthOfYear) {
case 2:
return ($year === null || Year::isLeap($year)) ? 29 : 28;

case 4:
case 6:
case 9:
case 11:
return 30;

default:
return 31;
}
return match ($monthOfYear) {
2 => ($year === null || Year::isLeap($year)) ? 29 : 28,
4, 6, 9, 11 => 30,
default => 31,
};
}

/**
Expand Down

0 comments on commit e758646

Please sign in to comment.