generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 199
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 add-indonesia-holiday
- Loading branch information
Showing
80 changed files
with
2,444 additions
and
55 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 |
---|---|---|
|
@@ -13,3 +13,6 @@ trim_trailing_whitespace = false | |
|
||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
|
||
[*.snap] | ||
insert_final_newline = false |
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,8 @@ | ||
# Contributing a new country ? | ||
|
||
* [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/spatie/holidays/pulls) for the same country? | ||
|
||
1. Create a new class in the Countries directory. It should extend the Country class. | ||
2. Add a test for the new country in the tests directory. | ||
3. Run the tests so a snapshot gets created. | ||
4. Verify the result in the newly created snapshot is correct. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
.php_cs | ||
.php_cs.cache | ||
.phpunit.cache | ||
.vscode | ||
build | ||
composer.lock | ||
coverage | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Bangladesh extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'bd'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'International Mother Language Day' => '02-21', | ||
'Birthday of Sheikh Mujibur Rahman' => '03-17', | ||
'Independence Day' => '03-26', | ||
'Bengali New Year' => '04-14', | ||
'May Day' => '05-01', | ||
'National Mourning Day' => '08-15', | ||
'Victory Day' => '12-16', | ||
'Christmas Day' => '12-25', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
// The variable holidays all follow the lunar calendar, so their dates are not confirmed. | ||
return []; | ||
} | ||
} |
Oops, something went wrong.