Skip to content

Commit

Permalink
fix: document InvalidDate thrown from Date (#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-challis authored Jul 2, 2024
1 parent cc307d0 commit 36f8586
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

final readonly class Date
{
/**
* @throws InvalidDate
*/
private function __construct(
private int $year,
private int $month,
Expand All @@ -18,6 +21,9 @@ private function __construct(
}
}

/**
* @throws InvalidDate
*/
public static function fromYearMonthDay(int $year, int $month, int $day): self
{
return new self($year, $month, $day);
Expand All @@ -32,6 +38,9 @@ public static function fromDateTime(\DateTimeInterface $dateTime): self
);
}

/**
* @throws InvalidDate
*/
public static function fromYearMonthDayString(string $value): self
{
$result = \preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value, $matches);
Expand Down

0 comments on commit 36f8586

Please sign in to comment.