Skip to content

Commit

Permalink
Switch back to stella-maris/clock
Browse files Browse the repository at this point in the history
This reverts commit a5e62af.
  • Loading branch information
jeromegamez committed Nov 25, 2022
1 parent 2ba952c commit 6ee3f31
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 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.0",
"psr/clock": "^1.0"
"stella-maris/clock": "^0.1.6"
},
"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 Psr\Clock\ClockInterface;
use StellaMaris\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 Psr\Clock\ClockInterface;
use StellaMaris\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 Psr\Clock\ClockInterface;
use StellaMaris\Clock\ClockInterface;

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

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

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

if (!method_exists($clock, 'now')) {
throw new InvalidArgumentException('$clock must implement '.ClockInterface::class.' or have a now() method');
throw new \InvalidArgumentException('$clock must implement StellaMaris\Clock\ClockInterface 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 @@ -40,13 +39,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 Psr\Clock\ClockInterface;
use StellaMaris\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 Psr\Clock\ClockInterface;
use StellaMaris\Clock\ClockInterface;

/**
* @internal
Expand Down

0 comments on commit 6ee3f31

Please sign in to comment.