Skip to content

Commit

Permalink
chore: convert const to variable in trait
Browse files Browse the repository at this point in the history
  • Loading branch information
maskeynihal committed Oct 18, 2024
1 parent 77405c5 commit db11650
Showing 1 changed file with 55 additions and 46 deletions.
101 changes: 55 additions & 46 deletions src/Calendars/NepaliCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait NepaliCalendar
/**
* Celebrated on the first day of the Bikram Sambat calendar. (Baishakh - 01/01)
*/
public const nepaliNewYear = [
public array $nepaliNewYear = [
'calendar' => 'Bikram Sambat',
'label' => 'Nepali New Year',
'dates' => [
Expand All @@ -25,7 +25,7 @@ trait NepaliCalendar
/**
* Celebrated on 15 Jestha - 02/15 of the Bikram Sambat calendar.
*/
public const nationalRepublicDay = [
public array $nationalRepublicDay = [
'calendar' => 'Bikram Sambat',
'label' => 'National Republic Day',
'dates' => [
Expand All @@ -36,7 +36,7 @@ trait NepaliCalendar
/**
* Celebrated on 27 Paush - 09/27 of the Bikram Sambat calendar.
*/
public const prithiviJayanti = [
public array $prithiviJayanti = [
'calendar' => 'Bikram Sambat',
'label' => 'Prithivi Jayanti',
'dates' => [
Expand All @@ -47,7 +47,7 @@ trait NepaliCalendar
/**
* Celebrated on 16 Magh - 10/16 of the Bikram Sambat calendar.
*/
public const martyrsDay = [
public array $martyrsDay = [
'calendar' => 'Bikram Sambat',
'label' => "Martyrs' Day",
'dates' => [
Expand All @@ -58,7 +58,7 @@ trait NepaliCalendar
/**
* Celebrated on 7 Falgun - 11/07 of the Bikram Sambat calendar.
*/
public const democracyDay = [
public array $democracyDay = [
'calendar' => 'Bikram Sambat',
'label' => 'Democracy Day',
'dates' => [
Expand All @@ -69,7 +69,7 @@ trait NepaliCalendar
/**
* Celebrated on 3 Ashwin - 04/03 of the Bikram Sambat calendar.
*/
public const constitutionDay = [
public array $constitutionDay = [
'calendar' => 'Bikram Sambat',
'label' => 'Constitution Day',
'dates' => [
Expand All @@ -80,7 +80,7 @@ trait NepaliCalendar
/**
* Celebrated on 1 Magh - 10/01 of the Bikram Sambat calendar.
*/
public const makarSankrantiHoliday = [
public array $makarSankrantiHoliday = [
'calendar' => 'Bikram Sambat',
'label' => 'Makar Sankranti',
'dates' => [
Expand All @@ -91,7 +91,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Celebrated on the first day of "Dashain" festival.
*/
public const ghatasthapanaHoliday = [
public array $ghatasthapanaHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Ghatasthapana (Dashain)',
'dates' => [
Expand All @@ -102,7 +102,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Celebrated on the 7th day of "Dashain" festival.
*/
public const fulpatiHoliday = [
public array $fulpatiHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Fulpati (Dashain)',
'dates' => [
Expand All @@ -113,7 +113,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Celebrated on the 8th day of "Dashain" festival.
*/
public const mahaNawamiHoliday = [
public array $mahaNawamiHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Maha Nawami (Dashain)',
'dates' => [
Expand All @@ -124,7 +124,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Celebrated on the 9th day of "Dashain" festival.
*/
public const mahaAsthamiHoliday = [
public array $mahaAsthamiHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Maha Asthami (Dashain)',
'dates' => [
Expand All @@ -135,7 +135,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Celebrated on the 10th day of "Dashain" festival.
*/
public const vijayaDashamiHoliday = [
public array $vijayaDashamiHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Vijaya Dashami (Dashain)',
'dates' => [
Expand All @@ -146,7 +146,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Celebrated on the 11th day of "Dashain" festival.
*/
public const ekadashiHoliday = [
public array $ekadashiHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Ekadashi (Dashain)',
'dates' => [
Expand All @@ -157,7 +157,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Celebrated on the 3rd day of "Tihar" festival.
*/
public const laxmiPujaHoliday = [
public array $laxmiPujaHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Laxmi Puja (Tihar)',
'dates' => [
Expand All @@ -168,7 +168,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Celebrated on the 4th day of "Tihar" festival.
*/
public const govardhanPujaHoliday = [
public array $govardhanPujaHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Govardhan Puja / Mha Puja (Tihar)',
'dates' => [
Expand All @@ -179,7 +179,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Celebrated on the 5th day of "Tihar" festival.
*/
public const bhaiTikaHoliday = [
public array $bhaiTikaHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Bhai Tika (Tihar)',
'dates' => [
Expand All @@ -190,7 +190,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Chhat Parva is a festival dedicated to the Sun God.
*/
public const chhatParvaHoliday = [
public array $chhatParvaHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Chhat Parva',
'dates' => [
Expand All @@ -201,7 +201,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Tamu Loshar is the New Year of the Gurung community.
*/
public const tamuLosharHoliday = [
public array $tamuLosharHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Tamu Loshar',
'dates' => [
Expand All @@ -212,7 +212,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Sonam Losar is the New Year of the Tamang community.
*/
public const sonamLosarHoliday = [
public array $sonamLosarHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Sonam Losar',
'dates' => [
Expand All @@ -223,7 +223,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Gyalpo Loshar is the New Year of the Sherpa community.
*/
public const gyalpoLosharHoliday = [
public array $gyalpoLosharHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Gyalpo Loshar',
'dates' => [
Expand All @@ -234,7 +234,7 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Udhauli Parva is the festival of the Kirat community.
*/
public const udhauliParvaHoliday = [
public array $udhauliParvaHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Udhauli Parva',
'dates' => [
Expand All @@ -245,56 +245,65 @@ trait NepaliCalendar
/**
* Celebrated on according to lunar calendar. Mahashivaratri is a Hindu festival dedicated to Lord Shiva.
*/
public const mahashivaratriHoliday = [
public array $mahashivaratriHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Maha Shivaratri',
'dates' => [
2025 => '02-26',
],
];

public const holiHoliday = [
/**
* Celebrated on according to lunar calendar.
*/
public array $holiHoliday = [
'calendar' => 'Lunar Calendar',
'label' => 'Holi / Fagu Purnima',
'dates' => [
2025 => '03-13',
],
];

/**
* Holidays according to Bikram Sambat calendar.
*/
public function holidaysAccordingToBikramSambatCalendar(int $year): array
{
$holidays = [
self::nepaliNewYear['label'] => self::nepaliNewYear['dates'][$year] ?? null,
self::nationalRepublicDay['label'] => self::nationalRepublicDay['dates'][$year] ?? null,
self::prithiviJayanti['label'] => self::prithiviJayanti['dates'][$year] ?? null,
self::martyrsDay['label'] => self::martyrsDay['dates'][$year] ?? null,
self::democracyDay['label'] => self::democracyDay['dates'][$year] ?? null,
self::constitutionDay['label'] => self::constitutionDay['dates'][$year] ?? null,
self::makarSankrantiHoliday['label'] => self::makarSankrantiHoliday['dates'][$year] ?? null,
$this->nepaliNewYear['label'] => $this->nepaliNewYear['dates'][$year] ?? null,
$this->nationalRepublicDay['label'] => $this->nationalRepublicDay['dates'][$year] ?? null,
$this->prithiviJayanti['label'] => $this->prithiviJayanti['dates'][$year] ?? null,
$this->martyrsDay['label'] => $this->martyrsDay['dates'][$year] ?? null,
$this->democracyDay['label'] => $this->democracyDay['dates'][$year] ?? null,
$this->constitutionDay['label'] => $this->constitutionDay['dates'][$year] ?? null,
$this->makarSankrantiHoliday['label'] => $this->makarSankrantiHoliday['dates'][$year] ?? null,
];

return array_filter($holidays, fn ($holiday) => $holiday !== null);
}

/**
* Holidays according to lunar calendar.
*/
public function holidaysAccordingToLunarCalendar(int $year): array
{
$holidays = [
self::ghatasthapanaHoliday['label'] => self::ghatasthapanaHoliday['dates'][$year] ?? null,
self::fulpatiHoliday['label'] => self::fulpatiHoliday['dates'][$year] ?? null,
self::mahaNawamiHoliday['label'] => self::mahaNawamiHoliday['dates'][$year] ?? null,
self::mahaAsthamiHoliday['label'] => self::mahaAsthamiHoliday['dates'][$year] ?? null,
self::vijayaDashamiHoliday['label'] => self::vijayaDashamiHoliday['dates'][$year] ?? null,
self::ekadashiHoliday['label'] => self::ekadashiHoliday['dates'][$year] ?? null,
self::laxmiPujaHoliday['label'] => self::laxmiPujaHoliday['dates'][$year] ?? null,
self::govardhanPujaHoliday['label'] => self::govardhanPujaHoliday['dates'][$year] ?? null,
self::bhaiTikaHoliday['label'] => self::bhaiTikaHoliday['dates'][$year] ?? null,
self::chhatParvaHoliday['label'] => self::chhatParvaHoliday['dates'][$year] ?? null,
self::tamuLosharHoliday['label'] => self::tamuLosharHoliday['dates'][$year] ?? null,
self::sonamLosarHoliday['label'] => self::sonamLosarHoliday['dates'][$year] ?? null,
self::gyalpoLosharHoliday['label'] => self::gyalpoLosharHoliday['dates'][$year] ?? null,
self::udhauliParvaHoliday['label'] => self::udhauliParvaHoliday['dates'][$year] ?? null,
self::mahashivaratriHoliday['label'] => self::mahashivaratriHoliday['dates'][$year] ?? null,
self::holiHoliday['label'] => self::holiHoliday['dates'][$year] ?? null,
$this->ghatasthapanaHoliday['label'] => $this->ghatasthapanaHoliday['dates'][$year] ?? null,
$this->fulpatiHoliday['label'] => $this->fulpatiHoliday['dates'][$year] ?? null,
$this->mahaNawamiHoliday['label'] => $this->mahaNawamiHoliday['dates'][$year] ?? null,
$this->mahaAsthamiHoliday['label'] => $this->mahaAsthamiHoliday['dates'][$year] ?? null,
$this->vijayaDashamiHoliday['label'] => $this->vijayaDashamiHoliday['dates'][$year] ?? null,
$this->ekadashiHoliday['label'] => $this->ekadashiHoliday['dates'][$year] ?? null,
$this->laxmiPujaHoliday['label'] => $this->laxmiPujaHoliday['dates'][$year] ?? null,
$this->govardhanPujaHoliday['label'] => $this->govardhanPujaHoliday['dates'][$year] ?? null,
$this->bhaiTikaHoliday['label'] => $this->bhaiTikaHoliday['dates'][$year] ?? null,
$this->chhatParvaHoliday['label'] => $this->chhatParvaHoliday['dates'][$year] ?? null,
$this->tamuLosharHoliday['label'] => $this->tamuLosharHoliday['dates'][$year] ?? null,
$this->sonamLosarHoliday['label'] => $this->sonamLosarHoliday['dates'][$year] ?? null,
$this->gyalpoLosharHoliday['label'] => $this->gyalpoLosharHoliday['dates'][$year] ?? null,
$this->udhauliParvaHoliday['label'] => $this->udhauliParvaHoliday['dates'][$year] ?? null,
$this->mahashivaratriHoliday['label'] => $this->mahashivaratriHoliday['dates'][$year] ?? null,
$this->holiHoliday['label'] => $this->holiHoliday['dates'][$year] ?? null,
];

return array_filter($holidays, fn ($holiday) => $holiday !== null);
Expand Down

0 comments on commit db11650

Please sign in to comment.