Skip to content

Commit

Permalink
Add guard methods for Moment (#56)
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Kolb <[email protected]>
  • Loading branch information
christian-kolb and Christian Kolb authored Jun 23, 2024
1 parent 0df267f commit bf14894
Show file tree
Hide file tree
Showing 55 changed files with 2,310 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ jobs:
run: make php-8.2-tests-ci

- name: Upload to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODE_COV_TOKEN }}
fail_ci_if_error: true
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

test-8-3:
Expand Down
3 changes: 3 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@

// Nullable types should be explicit even with default values
'nullable_type_declaration_for_default_null_value' => false,

// Throw in a single line is worse to read when using ternary operator
'single_line_throw' => false,
])
->setFinder($finder);
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.11.0

- Added `Clock` implementation with `SystemClock` and `FrozenClock`.
- Added guard methods for comparison methods to `Moment` like `mustBeEqualTo` with option to throw custom exception.

## 0.10.0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Additionally, the package provides a streamlined way to have the system running

This Symfony bundle includes Symfony normalizers for automatic normalization and denormalization and Doctrine types to store the objects directly in the database.

As it's a central part of an application, it's tested thoroughly (including mutation testing).
As it's a central part of an application, it's tested thoroughly (including mutation testing). Currently, more than 80% of the lines of code in this repository are tests.

[![Latest Stable Version](http://poser.pugx.org/digital-craftsman/date-time-precision/v)](https://packagist.org/packages/digital-craftsman/date-time-precision)
[![PHP Version Require](http://poser.pugx.org/digital-craftsman/date-time-precision/require/php)](https://packagist.org/packages/digital-craftsman/date-time-precision)
Expand Down
18 changes: 18 additions & 0 deletions src/Exception/MomentIsAfter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Exception;

/**
* @psalm-immutable
*
* @codeCoverageIgnore
*/
final class MomentIsAfter extends \InvalidArgumentException
{
public function __construct()
{
parent::__construct('The moment is after but must not be.');
}
}
18 changes: 18 additions & 0 deletions src/Exception/MomentIsAfterOrEqualTo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Exception;

/**
* @psalm-immutable
*
* @codeCoverageIgnore
*/
final class MomentIsAfterOrEqualTo extends \InvalidArgumentException
{
public function __construct()
{
parent::__construct('The moment is after or equal to but must not be.');
}
}
18 changes: 18 additions & 0 deletions src/Exception/MomentIsBefore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Exception;

/**
* @psalm-immutable
*
* @codeCoverageIgnore
*/
final class MomentIsBefore extends \InvalidArgumentException
{
public function __construct()
{
parent::__construct('The moment is before but must not be.');
}
}
18 changes: 18 additions & 0 deletions src/Exception/MomentIsBeforeOrEqualTo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Exception;

/**
* @psalm-immutable
*
* @codeCoverageIgnore
*/
final class MomentIsBeforeOrEqualTo extends \InvalidArgumentException
{
public function __construct()
{
parent::__construct('The moment is before or equal to but must not be.');
}
}
18 changes: 18 additions & 0 deletions src/Exception/MomentIsEqual.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Exception;

/**
* @psalm-immutable
*
* @codeCoverageIgnore
*/
final class MomentIsEqual extends \InvalidArgumentException
{
public function __construct()
{
parent::__construct('The moment is equal but must not be.');
}
}
18 changes: 18 additions & 0 deletions src/Exception/MomentIsNotAfter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Exception;

/**
* @psalm-immutable
*
* @codeCoverageIgnore
*/
final class MomentIsNotAfter extends \InvalidArgumentException
{
public function __construct()
{
parent::__construct('The moment is not after but must be.');
}
}
18 changes: 18 additions & 0 deletions src/Exception/MomentIsNotAfterOrEqualTo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Exception;

/**
* @psalm-immutable
*
* @codeCoverageIgnore
*/
final class MomentIsNotAfterOrEqualTo extends \InvalidArgumentException
{
public function __construct()
{
parent::__construct('The moment is not after or equal to but must be.');
}
}
18 changes: 18 additions & 0 deletions src/Exception/MomentIsNotBefore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Exception;

/**
* @psalm-immutable
*
* @codeCoverageIgnore
*/
final class MomentIsNotBefore extends \InvalidArgumentException
{
public function __construct()
{
parent::__construct('The moment is not before but must be.');
}
}
18 changes: 18 additions & 0 deletions src/Exception/MomentIsNotBeforeOrEqualTo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Exception;

/**
* @psalm-immutable
*
* @codeCoverageIgnore
*/
final class MomentIsNotBeforeOrEqualTo extends \InvalidArgumentException
{
public function __construct()
{
parent::__construct('The moment is not before or equal to but must be.');
}
}
18 changes: 18 additions & 0 deletions src/Exception/MomentIsNotEqual.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Exception;

/**
* @psalm-immutable
*
* @codeCoverageIgnore
*/
final class MomentIsNotEqual extends \InvalidArgumentException
{
public function __construct()
{
parent::__construct('The moment is not equal but must be.');
}
}
Loading

0 comments on commit bf14894

Please sign in to comment.