Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Exceptions/Assert/Assert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Gammadia\DateTimeExtra\Exceptions\Assert;

use Gammadia\DateTimeExtra\Exceptions\InvalidArgumentException;

class Assert extends \Webmozart\Assert\Assert
{
protected static function reportInvalidArgument($message)
{
throw new InvalidArgumentException($message);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}
9 changes: 9 additions & 0 deletions src/Exceptions/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Gammadia\DateTimeExtra\Exceptions;

interface ExceptionInterface extends \Throwable
{
}
2 changes: 1 addition & 1 deletion src/Exceptions/IntervalParseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use RuntimeException;
use Throwable;

final class IntervalParseException extends RuntimeException
final class IntervalParseException extends RuntimeException implements ExceptionInterface
{
public static function uniqueDuration(string $textToParse): self
{
Expand Down
10 changes: 10 additions & 0 deletions src/Exceptions/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Gammadia\DateTimeExtra\Exceptions;

class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{

}
3 changes: 2 additions & 1 deletion src/LocalDateInterval.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Brick\DateTime\Period;
use Brick\DateTime\YearWeek;
use Doctrine\ORM\Mapping as ORM;
use Gammadia\DateTimeExtra\Exceptions\Assert\Assert as DomainAssert;
use Gammadia\DateTimeExtra\Exceptions\IntervalParseException;
use JsonSerializable;
use RuntimeException;
Expand All @@ -29,7 +30,7 @@ private function __construct(
#[ORM\Column(type: 'local_date')]
private ?LocalDate $end,
) {
Assert::false($start && $end && $start->isAfter($end), sprintf('Start after end: %s / %s', $start, $end));
DomainAssert::false($start && $end && $start->isAfter($end), sprintf('Start after end: %s / %s', $start, $end));
}

public function __toString(): string
Expand Down