Skip to content

Commit 3270ed4

Browse files
committed
CLEAN: AN-23685 - add a dedicated DateFormattingException instead of using a generic one.
1 parent d6ed993 commit 3270ed4

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AssoConnect\PHPDateBundle\Exception;
6+
7+
use AssoConnect\PHPDate\AbsoluteDate;
8+
use LogicException;
9+
10+
class DateFormattingException extends LogicException
11+
{
12+
public const CANNOT_GET_PATTERN_MESSAGE = 'Cannot get pattern for date %s';
13+
public const CANNOT_FORMAT_DATE_MESSAGE = 'Cannot format date %s';
14+
15+
public static function cannotGetPattern(AbsoluteDate $absoluteDate): self
16+
{
17+
return new self(
18+
sprintf(self::CANNOT_GET_PATTERN_MESSAGE, $absoluteDate->__toString())
19+
);
20+
}
21+
22+
public static function cannotFormatDate(AbsoluteDate $absoluteDate): self
23+
{
24+
return new self(
25+
sprintf(self::CANNOT_FORMAT_DATE_MESSAGE, $absoluteDate->__toString())
26+
);
27+
}
28+
}

0 commit comments

Comments
 (0)