Skip to content

Commit 8adb14c

Browse files
authored
Merge pull request #334 from patchlevel/psr-clock
support PSR-20 ClockInterface
2 parents a20607b + 4de99b4 commit 8adb14c

File tree

5 files changed

+58
-9
lines changed

5 files changed

+58
-9
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"php": "~8.1.0",
2323
"doctrine/dbal": "^3.4.2",
2424
"psr/cache": "^2.0.0|^3.0.0",
25+
"psr/clock": "^1.0",
2526
"psr/log": "^2.0.0|^3.0.0",
2627
"psr/simple-cache": "^2.0.0|^3.0.0",
2728
"symfony/console": "^5.4.1|^6.0.1",

composer.lock

Lines changed: 50 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pages/clock.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ purposes. We are using this clock to create the `recorded_on` datetime for the e
55

66
!!! note
77

8-
The `Clock` interface will be PSR-20 compatible as soon at it is published. For more information see [here](https://github.com/php-fig/fig-standards/blob/master/proposed/clock.md).
8+
The `Clock` interface is PSR-20 compatible. For more information see [here](https://github.com/php-fig/fig-standards/blob/master/proposed/clock.md).
99

1010
## SystemClock
1111

src/Clock/Clock.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
namespace Patchlevel\EventSourcing\Clock;
66

7-
use DateTimeImmutable;
7+
use Psr\Clock\ClockInterface;
88

9-
interface Clock
9+
interface Clock extends ClockInterface
1010
{
11-
public function now(): DateTimeImmutable;
1211
}

src/EventBus/Decorator/RecordedOnDecorator.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
namespace Patchlevel\EventSourcing\EventBus\Decorator;
66

7-
use Patchlevel\EventSourcing\Clock\Clock;
87
use Patchlevel\EventSourcing\EventBus\Message;
8+
use Psr\Clock\ClockInterface;
99

1010
final class RecordedOnDecorator implements MessageDecorator
1111
{
12-
public function __construct(private readonly Clock $clock)
13-
{
12+
public function __construct(
13+
private readonly ClockInterface $clock
14+
) {
1415
}
1516

1617
public function __invoke(Message $message): Message

0 commit comments

Comments
 (0)