Skip to content

Commit

Permalink
Merge pull request #36 from BurtDS/main
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jan 17, 2024
2 parents 9927780 + 0e885c0 commit 4e609d6
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Countries/Andorra.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Andorra extends Country
{
public function countryCode(): string
{
return 'ad';
}

/** @return array<string, CarbonImmutable> */
protected function allHolidays(int $year): array
{
return array_merge([

Check failure on line 17 in src/Countries/Andorra.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Spatie\Holidays\Countries\Andorra::allHolidays() should return array<string, Carbon\CarbonImmutable> but returns array<string, Carbon\CarbonImmutable|string>.
'Any nou' => '01-01',
'Reis' => '01-06',
'Dia de la Constitució' => '03-14',
'Festa del Treball' => '05-01',
'Assumpció' => '08-15',
'Mare de Déu de Meritxell' => '09-08',
'Tots Sants' => '11-01',
'Immaculada Concepció' => '11-08',
'Nadal' => '12-25',
'Sant Esteve' => '12-26',
], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
$easter = CarbonImmutable::createFromTimestamp(easter_date($year))
->setTimezone('Europe/Brussels');

return [
'Divendres Sant' => $easter->subDays(2),
'Dilluns de Pasqua' => $easter->addDay(),
'Dilluns de Pentecosta' => $easter->addDays(50),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"name": "Any nou",
"date": "2024-01-01"
},
{
"name": "Reis",
"date": "2024-01-06"
},
{
"name": "Dia de la Constituci\u00f3",
"date": "2024-03-14"
},
{
"name": "Divendres Sant",
"date": "2024-03-29"
},
{
"name": "Dilluns de Pasqua",
"date": "2024-04-01"
},
{
"name": "Festa del Treball",
"date": "2024-05-01"
},
{
"name": "Dilluns de Pentecosta",
"date": "2024-05-20"
},
{
"name": "Assumpci\u00f3",
"date": "2024-08-15"
},
{
"name": "Mare de D\u00e9u de Meritxell",
"date": "2024-09-08"
},
{
"name": "Tots Sants",
"date": "2024-11-01"
},
{
"name": "Immaculada Concepci\u00f3",
"date": "2024-11-08"
},
{
"name": "Nadal",
"date": "2024-12-25"
},
{
"name": "Sant Esteve",
"date": "2024-12-26"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/AndorraTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Spatie\Holidays\Tests\Countries;

use Carbon\CarbonImmutable;
use Spatie\Holidays\Holidays;

it('can calculate andorra holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

$holidays = Holidays::for(country: 'ad')->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(formatDates($holidays))->toMatchSnapshot();
});

0 comments on commit 4e609d6

Please sign in to comment.