generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'spatie:main' into main
- Loading branch information
Showing
26 changed files
with
453 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
name: Fix PHP code style issues | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.php' | ||
on: [push] | ||
|
||
permissions: | ||
contents: write | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: PHPStan | ||
|
||
on: [push] | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
phpstan: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use Spatie\Holidays\Countries\Country; | ||
use Spatie\Holidays\Holidays; | ||
|
||
use function Laravel\Prompts\select; | ||
|
||
require __DIR__.'/vendor/autoload.php'; | ||
|
||
$countries = []; | ||
|
||
foreach (glob(__DIR__.'/src/Countries/*.php') as $filename) { // @phpstan-ignore-line | ||
$countryClass = '\\Spatie\\Holidays\\Countries\\'.basename($filename, '.php'); | ||
|
||
if (basename($filename) === 'Country.php') { | ||
continue; | ||
} | ||
|
||
$countries[$countryClass] = str_replace('\\Spatie\\Holidays\\Countries\\', '', $countryClass); | ||
} | ||
|
||
/** @var Country $class */ | ||
$class = select('Select a country', $countries); | ||
|
||
$result = collect(Holidays::for($class::make())->get()) | ||
->map(fn (array $holiday) => [ | ||
'name' => $holiday['name'], | ||
'date' => $holiday['date']->format('Y-m-d'), // @phpstan-ignore-line | ||
])->toArray(); | ||
|
||
dd($result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Denmark extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'da'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Nytår' => '01-01', | ||
'Juleaften' => '12-24', | ||
'Juledag' => '12-25', | ||
'Anden Juledag' => '12-26', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = CarbonImmutable::createFromTimestamp(easter_date($year)) | ||
->setTimezone('Europe/Copenhagen'); | ||
|
||
$holidays = [ | ||
'Påskedag' => $easter->addDay(), | ||
'Skærtorsdag' => $easter->subDays(3), | ||
'Langfredag' => $easter->subDays(2), | ||
'Anden Påskedag' => $easter->addDays(2), | ||
'Kristi Himmelfartsdag' => $easter->addDays(39), | ||
'Pinse' => $easter->addDays(49), | ||
'Anden Pinsedag' => $easter->addDays(50), | ||
]; | ||
|
||
if ($year < 2024) { | ||
$holidays['Store Bededag'] = $easter->addDays(26); | ||
} | ||
|
||
return $holidays; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Portugal extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'pt'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Dia de Ano Novo' => '01-01', | ||
'Dia da Liberdade' => '04-25', | ||
'Dia do Trabalhador' => '05-01', | ||
'Dia de Portugal' => '06-10', | ||
'Assunção da Nossa Senhora' => '08-15', | ||
'Implantação da República' => '10-05', | ||
'Dia de Todos os Santos' => '11-01', | ||
'Restauração da Independência' => '12-01', | ||
'Imaculada Conceição' => '12-08', | ||
'Natal' => '12-25', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = CarbonImmutable::createFromTimestamp(easter_date($year)) | ||
->setTimezone('Europe/Lisbon'); | ||
|
||
return [ | ||
'Páscoa' => $easter, | ||
'Sexta-feira Santa' => $easter->subDays(2), | ||
'Corpo de Deus' => $easter->addDays(60), | ||
]; | ||
} | ||
} |
Oops, something went wrong.