Skip to content
Merged
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
3 changes: 1 addition & 2 deletions .junie/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

## Folder structure

- `src/Code` folder contains the framework internal code
- `src/Abstract` folder contains the framework internal code
- other folders like `src/"type"` contains specific types
- `src/psalmTest.php` contains types usage to avoid Psalm issues like `unused method`
- `src/Code/Assert/Assert.php` contains `assert` methods, add new methods instead of checking conditions directly in classes. Prefer to use Assert::"methos()".

## Tests

Expand Down
6 changes: 3 additions & 3 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ declare(strict_types=1);

namespace App\Domain;

use PhpTypedValues\Code\Assert\Assert;
use PhpTypedValues\Code\Exception\FloatTypeException;
use PhpTypedValues\Code\Integer\IntType;
use PhpTypedValues\Abstract\Assert\Assert;
use PhpTypedValues\Exception\FloatTypeException;
use PhpTypedValues\Abstract\Integer\IntType;

final class EvenPositiveInt extends IntType
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\DateTime;
namespace PhpTypedValues\Abstract\DateTime;

use const PHP_EOL;

use DateTimeImmutable;
use DateTimeZone;
use PhpTypedValues\Code\Exception\DateTimeTypeException;
use PhpTypedValues\Code\Exception\ReasonableRangeDateTimeTypeException;
use PhpTypedValues\Exception\DateTimeTypeException;
use PhpTypedValues\Exception\ReasonableRangeDateTimeTypeException;

use function count;
use function sprintf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\DateTime;
namespace PhpTypedValues\Abstract\DateTime;

use DateTimeImmutable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\Float;
namespace PhpTypedValues\Abstract\Float;

use PhpTypedValues\Code\Exception\FloatTypeException;
use PhpTypedValues\Exception\FloatTypeException;

use function sprintf;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\Float;
namespace PhpTypedValues\Abstract\Float;

/**
* @psalm-immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\Integer;
namespace PhpTypedValues\Abstract\Integer;

use PhpTypedValues\Code\Exception\IntegerTypeException;
use PhpTypedValues\Exception\IntegerTypeException;

use function sprintf;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\Integer;
namespace PhpTypedValues\Abstract\Integer;

/**
* @psalm-immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\String;
namespace PhpTypedValues\Abstract\String;

/**
* @psalm-immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\String;
namespace PhpTypedValues\Abstract\String;

/**
* @psalm-immutable
Expand Down
6 changes: 4 additions & 2 deletions src/DateTime/DateTimeAtom.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

use DateTimeImmutable;
use DateTimeZone;
use PhpTypedValues\Code\DateTime\DateTimeType;
use PhpTypedValues\Code\Exception\DateTimeTypeException;
use PhpTypedValues\Abstract\DateTime\DateTimeType;
use PhpTypedValues\Exception\DateTimeTypeException;

/**
* ATOM RFC 3339 format based on ISO 8601.
*
* Example "2025-01-02T03:04:05+00:00"
*
* @psalm-immutable
*/
readonly class DateTimeAtom extends DateTimeType
Expand Down
6 changes: 4 additions & 2 deletions src/DateTime/DateTimeRFC3339.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

use DateTimeImmutable;
use DateTimeZone;
use PhpTypedValues\Code\DateTime\DateTimeType;
use PhpTypedValues\Code\Exception\DateTimeTypeException;
use PhpTypedValues\Abstract\DateTime\DateTimeType;
use PhpTypedValues\Exception\DateTimeTypeException;

/**
* RFC 3339 format based on ISO 8601.
*
* Example "2025-01-02T03:04:05+00:00"
*
* @psalm-immutable
*/
readonly class DateTimeRFC3339 extends DateTimeType
Expand Down
8 changes: 5 additions & 3 deletions src/DateTime/DateTimeRFC3339Extended.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

use DateTimeImmutable;
use DateTimeZone;
use PhpTypedValues\Code\DateTime\DateTimeType;
use PhpTypedValues\Code\Exception\DateTimeTypeException;
use PhpTypedValues\Abstract\DateTime\DateTimeType;
use PhpTypedValues\Exception\DateTimeTypeException;

/**
* RFC 3339 EXTENDED format based on ISO 8601.
* RFC 3339 EXTENDED format based on ISO 8601 (with microseconds).
*
* Example "2025-01-02T03:04:05.123456+00:00"
*
* @psalm-immutable
*/
Expand Down
6 changes: 4 additions & 2 deletions src/DateTime/DateTimeW3C.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

use DateTimeImmutable;
use DateTimeZone;
use PhpTypedValues\Code\DateTime\DateTimeType;
use PhpTypedValues\Code\Exception\DateTimeTypeException;
use PhpTypedValues\Abstract\DateTime\DateTimeType;
use PhpTypedValues\Exception\DateTimeTypeException;

/**
* W3C RFC 3339 format based on ISO 8601.
*
* Example "2025-01-02T03:04:05+00:00"
*
* @psalm-immutable
*/
readonly class DateTimeW3C extends DateTimeType
Expand Down
8 changes: 5 additions & 3 deletions src/DateTime/Timestamp/TimestampMilliseconds.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
namespace PhpTypedValues\DateTime\Timestamp;

use DateTimeZone;
use PhpTypedValues\Code\DateTime\DateTimeType;
use PhpTypedValues\Code\Exception\DateTimeTypeException;
use PhpTypedValues\Abstract\DateTime\DateTimeType;
use PhpTypedValues\Exception\DateTimeTypeException;

use function intdiv;
use function sprintf;

/**
* Unix timestamp in milliseconds since Unix epoch (UTC), e.g. "1732445696123".
* Unix timestamp in milliseconds since Unix epoch (UTC).
*
* Example "1732445696123"
*
* @psalm-immutable
*/
Expand Down
8 changes: 5 additions & 3 deletions src/DateTime/Timestamp/TimestampSeconds.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
namespace PhpTypedValues\DateTime\Timestamp;

use DateTimeZone;
use PhpTypedValues\Code\DateTime\DateTimeType;
use PhpTypedValues\Code\Exception\DateTimeTypeException;
use PhpTypedValues\Abstract\DateTime\DateTimeType;
use PhpTypedValues\Exception\DateTimeTypeException;

/**
* Unix timestamp (seconds since Unix epoch, UTC), e.g. "1732445696".
* Unix timestamp (seconds since Unix epoch, UTC).
*
* Example "1732445696"
*
* @psalm-immutable
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\Exception;
namespace PhpTypedValues\Exception;

class DateTimeTypeException extends TypeException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\Exception;
namespace PhpTypedValues\Exception;

class FloatTypeException extends TypeException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\Exception;
namespace PhpTypedValues\Exception;

class IntegerTypeException extends TypeException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\Exception;
namespace PhpTypedValues\Exception;

class ReasonableRangeDateTimeTypeException extends DateTimeTypeException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\Exception;
namespace PhpTypedValues\Exception;

class StringTypeException extends TypeException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpTypedValues\Code\Exception;
namespace PhpTypedValues\Exception;

use Exception;

Expand Down
14 changes: 14 additions & 0 deletions src/Float/Alias/FloatType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace PhpTypedValues\Float\Alias;

use PhpTypedValues\Float\FloatStandard;

/**
* @psalm-immutable
*/
readonly class FloatType extends FloatStandard
{
}
4 changes: 4 additions & 0 deletions src/Float/Alias/NonNegativeFloat.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
use PhpTypedValues\Float\FloatNonNegative;

/**
* Alias of Non-negative float (>= 0.0).
*
* Example "0.0"
*
* @psalm-immutable
*/
readonly class NonNegativeFloat extends FloatNonNegative
Expand Down
8 changes: 6 additions & 2 deletions src/Float/FloatNonNegative.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

namespace PhpTypedValues\Float;

use PhpTypedValues\Code\Exception\FloatTypeException;
use PhpTypedValues\Code\Float\FloatType;
use PhpTypedValues\Abstract\Float\FloatType;
use PhpTypedValues\Exception\FloatTypeException;

use function sprintf;

/**
* Non-negative float (>= 0.0).
*
* Example "0.0"
*
* @psalm-immutable
*/
readonly class FloatNonNegative extends FloatType
Expand Down
6 changes: 4 additions & 2 deletions src/Float/FloatStandard.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

namespace PhpTypedValues\Float;

use PhpTypedValues\Code\Exception\FloatTypeException;
use PhpTypedValues\Code\Float\FloatType;
use PhpTypedValues\Abstract\Float\FloatType;
use PhpTypedValues\Exception\FloatTypeException;

/**
* Represents any PHP float (double).
*
* Example "3.14"
*
* @psalm-immutable
*/
readonly class FloatStandard extends FloatType
Expand Down
4 changes: 4 additions & 0 deletions src/Integer/Alias/Id.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
use PhpTypedValues\Integer\IntegerPositive;

/**
* Alias of Positive integer used as identifier.
*
* Example "42"
*
* @psalm-immutable
*/
readonly class Id extends IntegerPositive
Expand Down
14 changes: 14 additions & 0 deletions src/Integer/Alias/IntType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace PhpTypedValues\Integer\Alias;

use PhpTypedValues\Integer\IntegerStandard;

/**
* @psalm-immutable
*/
readonly class IntType extends IntegerStandard
{
}
4 changes: 4 additions & 0 deletions src/Integer/Alias/NonNegativeInt.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
use PhpTypedValues\Integer\IntegerNonNegative;

/**
* Alias of Non-negative integer (>= 0).
*
* Example "0"
*
* @psalm-immutable
*/
readonly class NonNegativeInt extends IntegerNonNegative
Expand Down
4 changes: 4 additions & 0 deletions src/Integer/Alias/PositiveInt.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
use PhpTypedValues\Integer\IntegerPositive;

/**
* Alias of Positive integer (> 0).
*
* Example "1"
*
* @psalm-immutable
*/
readonly class PositiveInt extends IntegerPositive
Expand Down
8 changes: 6 additions & 2 deletions src/Integer/IntegerNonNegative.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

namespace PhpTypedValues\Integer;

use PhpTypedValues\Code\Exception\IntegerTypeException;
use PhpTypedValues\Code\Integer\IntType;
use PhpTypedValues\Abstract\Integer\IntType;
use PhpTypedValues\Exception\IntegerTypeException;

use function sprintf;

/**
* Non-negative integer (>= 0).
*
* Example "0"
*
* @psalm-immutable
*/
readonly class IntegerNonNegative extends IntType
Expand Down
Loading