Skip to content

Commit

Permalink
Add Month::getName() method (same as __toString())
Browse files Browse the repository at this point in the history
  • Loading branch information
gnutix committed Sep 30, 2023
1 parent 084395f commit 497b11e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Month.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ public function jsonSerialize(): string
return (string) $this;
}

/**
* {@see __toString()}.
*/
public function getName(): string
{
return (string) $this;
}

/**
* Returns the capitalized English name of this Month.
*/
Expand Down
11 changes: 11 additions & 0 deletions tests/MonthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,17 @@ public function testJsonSerialize(int $month, string $expectedName): void
self::assertSame(json_encode($expectedName), json_encode(Month::of($month)));
}

/**
* @dataProvider providerToString
*
* @param int $month The month number.
* @param string $expectedName The expected month name.
*/
public function testGetName(int $month, string $expectedName): void
{
self::assertSame($expectedName, Month::of($month)->getName());
}

/**
* @dataProvider providerToString
*
Expand Down

0 comments on commit 497b11e

Please sign in to comment.