Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach authored and github-actions[bot] committed Jun 13, 2024
1 parent ba2b3d6 commit dcea7ff
Showing 1 changed file with 28 additions and 33 deletions.
61 changes: 28 additions & 33 deletions src/Countries/Benin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

namespace Spatie\Holidays\Countries;

use Carbon\Carbon;
use Carbon\CarbonImmutable;
use GeniusTS\HijriDate\Date;
use GeniusTS\HijriDate\Hijri;

class Benin extends Country
{

public const ProphetMohammedBirthday = [
1970 => '05-17',
1971 => '05-07',
Expand Down Expand Up @@ -231,22 +229,22 @@ public function countryCode(): string
protected function allHolidays(int $year): array
{
return array_merge([
"Fête du Nouvel An" => '01-01',
"Fête annuelle des réligions traditionnelles" => '01-10',
"Fete annuelle des réligions traditionnelles" => '01-10',
"Fete du travail" => '05-01',
"Fête de l'indépendance" => '08-01',
"Jour de la Toussaint" => '11-01',
"Jour de Noel" => '12-25',
"Jour de l'assomption" => '08-15',
'Fête du Nouvel An' => '01-01',
'Fête annuelle des réligions traditionnelles' => '01-10',
'Fete annuelle des réligions traditionnelles' => '01-10',
'Fete du travail' => '05-01',
"Fête de l'indépendance" => '08-01',
'Jour de la Toussaint' => '11-01',
'Jour de Noel' => '12-25',
"Jour de l'assomption" => '08-15',
], $this->variableHolidays($year));
}

/**
* Some dates vary each year,as they are based on the Islamic Hijri (lunar) calendar. These holidays do not have a fixed date and
* occur based on the lunar calendar sequence. The order listed reflects the chronological occurrence
* of these holidays throughout the year.
* @param int $year
*
* @return array<string, CarbonImmutable>
*/
protected function variableHolidays(int $year): array
Expand All @@ -255,9 +253,9 @@ protected function variableHolidays(int $year): array

return array_merge(
[
"Lundi de Pâques" => $easter->addDays(1),
"Jour de l’Ascension" => $easter->addDays(40),
"Lundi de Pentecôte" => $easter->addDays(50),
'Lundi de Pâques' => $easter->addDays(1),
'Jour de l’Ascension' => $easter->addDays(40),
'Lundi de Pentecôte' => $easter->addDays(50),
],
$this->getIslamicHolidays(
year: $year,
Expand All @@ -280,23 +278,22 @@ protected function variableHolidays(int $year): array
}

/**
* @param array<int, string|array<string>> $holidays
* @param array<int, string|array<string>> $holidays
* @return array<string, CarbonImmutable>
*/
protected function getIslamicHolidays(
int $year,
array $holidays,
int $year,
array $holidays,
string $label,
int $day = 1,
): array
{
int $day = 1,
): array {
$islamicHolidays = [];
$counter = 0;

if ($year != 1970) {
$previousHoliday = is_array($holidays[$year - 1]) ? $holidays[$year - 1][1] : $holidays[$year - 1];

$previousHoliday = CarbonImmutable::createFromFormat('Y-m-d', ($year - 1) . '-' . $previousHoliday);
$previousHoliday = CarbonImmutable::createFromFormat('Y-m-d', ($year - 1).'-'.$previousHoliday);

if ($previousHoliday->addDays($day - 1)->year == $year) {
$islamicHolidays = $this->prepareHolidays(
Expand All @@ -319,23 +316,23 @@ protected function getIslamicHolidays(
day: $day,
label: $label,
filterYear: $year,
prefix: $counter ? ($counter + 1) . '. ' : ''
prefix: $counter ? ($counter + 1).'. ' : ''
));
$counter++;
}

if ($year != 2037) {
$nextHoliday = is_array($holidays[$year + 1]) ? $holidays[$year + 1][1] : $holidays[$year + 1];

$nextHoliday = CarbonImmutable::createFromFormat('Y-m-d', ($year + 1) . '-' . $nextHoliday);
$nextHoliday = CarbonImmutable::createFromFormat('Y-m-d', ($year + 1).'-'.$nextHoliday);

if ($nextHoliday->addDays(-1)->year == $year) {
$islamicHolidays = array_merge($islamicHolidays, $this->prepareHolidays(
holiday: $nextHoliday,
day: $day,
label: $label,
filterYear: $year,
prefix: $counter ? ($counter + 1) . '. ' : ''
prefix: $counter ? ($counter + 1).'. ' : ''
));
}
}
Expand All @@ -346,19 +343,17 @@ protected function getIslamicHolidays(
/** @return array<string, CarbonImmutable> */
protected function prepareHolidays(
CarbonImmutable $holiday,
int $day,
string $label,
int $filterYear,
string $prefix = ''
): array
{
int $day,
string $label,
int $filterYear,
string $prefix = ''
): array {
$holidays = [];

foreach (range(1, $day) as $range) {
$holidays[$prefix . $label . ' - Jour ' . $range] = $holiday->addDays($range - 1);
$holidays[$prefix.$label.' - Jour '.$range] = $holiday->addDays($range - 1);
}

return array_filter($holidays, fn($holiday) => $holiday->year == $filterYear);
return array_filter($holidays, fn ($holiday) => $holiday->year == $filterYear);
}

}

0 comments on commit dcea7ff

Please sign in to comment.