Skip to content

support PSR-20 ClockInterface #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2022
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"php": "~8.1.0",
"doctrine/dbal": "^3.4.2",
"psr/cache": "^2.0.0|^3.0.0",
"psr/clock": "^1.0",
"psr/log": "^2.0.0|^3.0.0",
"psr/simple-cache": "^2.0.0|^3.0.0",
"symfony/console": "^5.4.1|^6.0.1",
Expand Down
52 changes: 50 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pages/clock.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ purposes. We are using this clock to create the `recorded_on` datetime for the e

!!! note

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).
The `Clock` interface is PSR-20 compatible. For more information see [here](https://github.com/php-fig/fig-standards/blob/master/proposed/clock.md).

## SystemClock

Expand Down
5 changes: 2 additions & 3 deletions src/Clock/Clock.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

namespace Patchlevel\EventSourcing\Clock;

use DateTimeImmutable;
use Psr\Clock\ClockInterface;

interface Clock
interface Clock extends ClockInterface
{
public function now(): DateTimeImmutable;
}
7 changes: 4 additions & 3 deletions src/EventBus/Decorator/RecordedOnDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

namespace Patchlevel\EventSourcing\EventBus\Decorator;

use Patchlevel\EventSourcing\Clock\Clock;
use Patchlevel\EventSourcing\EventBus\Message;
use Psr\Clock\ClockInterface;

final class RecordedOnDecorator implements MessageDecorator
{
public function __construct(private readonly Clock $clock)
{
public function __construct(
private readonly ClockInterface $clock
) {
}

public function __invoke(Message $message): Message
Expand Down