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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- Require PHP `8.4`
- Require `innmind/immutable:~6.0`
- Require `innmind/time-continuum:~5.0`
- Require `innmind/time:~1.0`

## 2.3.0 - 2025-09-15

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require": {
"php": "~8.4",
"innmind/immutable": "~6.0",
"innmind/time-continuum": "~5.0"
"innmind/time": "~1.0"
},
"autoload": {
"psr-4": {
Expand Down
44 changes: 9 additions & 35 deletions proofs/pointInTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,24 @@
declare(strict_types = 1);

use Innmind\Validation\PointInTime;
use Innmind\TimeContinuum\{
Earth,
Earth\Format\ISO8601,
use Innmind\Time\{
Clock,
Format,
};
use Innmind\BlackBox\Set;
use Fixtures\Innmind\TimeContinuum\{
PointInTime as FPointInTime,
Earth as FEarth,
};
use Fixtures\Innmind\Time\Point as FPoint;

return static function() {
yield proof(
'PointInTime::ofFormat()',
given(
match (true) {
\class_exists(FEarth\PointInTime::class) => FEarth\PointInTime::any(),
default => FPointInTime::any(),
},
FPoint::any(),
Set::strings(),
),
static function($assert, $point, $random) {
$format = match (true) {
\class_exists(ISO8601::class) => new ISO8601,
default => Format::of('Y-m-d\TH:i:s.uP'), // to support microseconds
};
$format = Format::of('Y-m-d\TH:i:s.uP'); // to support microseconds
$string = $point->format($format);
$clock = match (true) {
\class_exists(Earth\Clock::class) => new Earth\Clock,
default => Clock::live(),
};
$clock = Clock::live();

$assert->true(
PointInTime::ofFormat($clock, $format)->asPredicate()($string),
Expand Down Expand Up @@ -72,14 +58,8 @@ static function($assert, $point, $random) {
Set::strings(),
),
static function($assert, $expected, $random) {
$format = match (true) {
\class_exists(ISO8601::class) => new ISO8601,
default => Format::iso8601(),
};
$clock = match (true) {
\class_exists(Earth\Clock::class) => new Earth\Clock,
default => Clock::live(),
};
$format = Format::iso8601();
$clock = Clock::live();

[[$path, $message]] = PointInTime::ofFormat($clock, $format)->withFailure($expected)($random)->match(
static fn() => null,
Expand All @@ -97,14 +77,8 @@ static function($assert, $expected, $random) {
yield test(
'PointInTime::ofFormat() with empty string fails',
static function($assert) {
$format = match (true) {
\class_exists(ISO8601::class) => new ISO8601,
default => Format::iso8601(),
};
$clock = match (true) {
\class_exists(Earth\Clock::class) => new Earth\Clock,
default => Clock::live(),
};
$format = Format::iso8601();
$clock = Clock::live();

[[$path, $message]] = PointInTime::ofFormat($clock, $format)('')->match(
static fn() => null,
Expand Down
2 changes: 1 addition & 1 deletion src/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Constraint\Implementation,
Constraint\Provider,
};
use Innmind\TimeContinuum\Clock;
use Innmind\Time\Clock;
use Innmind\Immutable\{
Validation,
Predicate,
Expand Down
8 changes: 4 additions & 4 deletions src/Constraint/PointInTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
namespace Innmind\Validation\Constraint;

use Innmind\Validation\Failure;
use Innmind\TimeContinuum\{
use Innmind\Time\{
Clock,
Format,
PointInTime as PointInTimeInterface,
Point,
};
use Innmind\Immutable\Validation;

/**
* @internal
* @implements Implementation<string, PointInTimeInterface>
* @implements Implementation<string, Point>
* @psalm-immutable
*/
final class PointInTime implements Implementation
Expand All @@ -27,7 +27,7 @@ private function __construct(
/**
* @param string $value
*
* @return Validation<Failure, PointInTimeInterface>
* @return Validation<Failure, Point>
*/
#[\Override]
public function __invoke(mixed $value): Validation
Expand Down
8 changes: 4 additions & 4 deletions src/Constraint/Provider/Clock.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
Constraint,
Constraint\Implementation,
};
use Innmind\TimeContinuum\{
use Innmind\Time\{
Clock as Concrete,
Format,
PointInTime,
Point,
};

/**
Expand Down Expand Up @@ -42,12 +42,12 @@ public static function of(\Closure $build, Concrete $clock): self
/**
* @template E
*
* @return Constraint<string, PointInTime>
* @return Constraint<string, Point>
*/
#[\NoDiscard]
public function format(Format $format): Constraint
{
/** @var Constraint<string, PointInTime> */
/** @var Constraint<string, Point> */
return ($this->build)(Constraint\PointInTime::ofFormat(
$this->clock,
$format,
Expand Down
6 changes: 3 additions & 3 deletions src/PointInTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

namespace Innmind\Validation;

use Innmind\TimeContinuum\{
use Innmind\Time\{
Clock,
Format,
PointInTime as PointInTimeInterface,
Point,
};

/**
Expand All @@ -21,7 +21,7 @@ private function __construct()
/**
* @psalm-pure
*
* @return Constraint<string, PointInTimeInterface>
* @return Constraint<string, Point>
*/
#[\NoDiscard]
public static function ofFormat(Clock $clock, Format $format): Constraint
Expand Down