Skip to content

Commit

Permalink
Switch to the now released psr/clock-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Nov 25, 2022
1 parent 5acec11 commit a5e62af
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"require": {
"php": "~8.1.0 || ~8.2.0",
"stella-maris/clock": "^0.1.6"
"psr/clock": "^1.0"
},
"require-dev": {
"phpstan/extension-installer": "^1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/Clock.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Beste;

use StellaMaris\Clock\ClockInterface;
use Psr\Clock\ClockInterface;

interface Clock extends ClockInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Clock/FrozenClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Beste\Clock;
use DateTimeImmutable;
use DateTimeZone;
use StellaMaris\Clock\ClockInterface;
use Psr\Clock\ClockInterface;

final class FrozenClock implements Clock
{
Expand Down
2 changes: 1 addition & 1 deletion src/Clock/MinuteClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Beste\Clock;
use DateTimeImmutable;
use StellaMaris\Clock\ClockInterface;
use Psr\Clock\ClockInterface;

final class MinuteClock implements Clock
{
Expand Down
11 changes: 6 additions & 5 deletions src/Clock/WrappingClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

use Beste\Clock;
use DateTimeImmutable;
use StellaMaris\Clock\ClockInterface;
use InvalidArgumentException;
use Psr\Clock\ClockInterface;

final class WrappingClock implements Clock
{
Expand All @@ -24,11 +25,11 @@ public static function wrapping(object $clock): self
}

if (!method_exists($clock, 'now')) {
throw new \InvalidArgumentException('$clock must implement StellaMaris\Clock\ClockInterface or have a now() method');
throw new InvalidArgumentException('$clock must implement '.ClockInterface::class.' or have a now() method');
}

if (!($clock->now() instanceof DateTimeImmutable)) {
throw new \InvalidArgumentException('$clock->now() must return a DateTimeImmutable');
throw new InvalidArgumentException('$clock->now() must return a DateTimeImmutable');
}

$wrappedClock = new class($clock) implements ClockInterface {
Expand All @@ -39,13 +40,13 @@ public function __construct(object $clock)
$this->clock = $clock;
}

public function now(): \DateTimeImmutable
public function now(): DateTimeImmutable
{
assert(method_exists($this->clock, 'now'));

$now = $this->clock->now();

assert($now instanceof \DateTimeImmutable);
assert($now instanceof DateTimeImmutable);

return $now;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Clock/FrozenClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Beste\Clock\FrozenClock;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use StellaMaris\Clock\ClockInterface;
use Psr\Clock\ClockInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Clock/MinuteClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Beste\Clock\MinuteClock;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use StellaMaris\Clock\ClockInterface;
use Psr\Clock\ClockInterface;

/**
* @internal
Expand Down

0 comments on commit a5e62af

Please sign in to comment.