Skip to content

Commit

Permalink
Migrated a few more methods (and tests). [WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
stelgenhof committed Oct 24, 2020
1 parent d92bbd5 commit df2a223
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Build Status](https://img.shields.io/travis/azuyalabs/yasumi.svg?style=flat-square)](https://travis-ci.org/azuyalabs/yasumi)
[![StyleCI](https://styleci.io/repos/32797151/shield?branch=master)](https://styleci.io/repos/32797151)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/azuyalabs/yasumi/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/azuyalabs/yasumi/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/azuyalabs/yasumi/badges/quality-score.png?b=tainted-uranium)](https://scrutinizer-ci.com/g/azuyalabs/yasumi/?branch=tainted-uranium)

Tainted Uranium
---------------
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"fzaninotto/faker": "^1.9",
"mikey179/vfsstream": "^1.6",
"phpspec/phpspec": "^6.2",
"phpunit/phpunit": "^9.3"
"phpunit/phpunit": "^9.4"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 7 additions & 1 deletion spec/Yasumi/Provider/Netherlands/LiberationDaySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ public function it_is_initializable(): void
{
$this->shouldHaveType(LiberationDay::class);
$this->shouldImplement(HolidayInterface::class);
$this->shouldImplement(\JsonSerializable::class);
}

public function it_should_return_holiday_key(): void
public function it_should_return_the_key_name(): void
{
$this->getKey()->shouldBe('liberationDay');
}
Expand All @@ -42,4 +43,9 @@ public function it_should_return_correct_holiday_date(): void
{
$this->format('Y-m-d')->shouldBe('2020-05-05');
}

public function it_should_return_date_string_when_called_as_string(): void
{
$this->__toString()->shouldBe('2020-05-05');
}
}
22 changes: 21 additions & 1 deletion src/Yasumi/BaseHoliday.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,32 @@

namespace Yasumi;

abstract class BaseHoliday extends \DateTimeImmutable implements HolidayInterface
abstract class BaseHoliday extends \DateTimeImmutable implements HolidayInterface, \JsonSerializable
{
protected const DATE_FORMAT = 'Y-m-d';

public function __construct($time = 'now', $timezone = null)
{
parent::__construct($time, $timezone);
}

/**
* Format the instance as a string using the set format.
*
* @return string this instance as a string using the set format
*/
public function __toString(): string
{
return $this->format(self::DATE_FORMAT);
}

/**
* Serializes the object to a value that can be serialized natively by json_encode().
*
* @return $this
*/
public function jsonSerialize(): self
{
return $this;
}
}

0 comments on commit df2a223

Please sign in to comment.