mirror of
https://github.com/beste/clock.git
synced 2026-10-17 19:27:35 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7004b55fcd | ||
|
|
ebd491dc6e | ||
|
|
cf2cc16e66 | ||
|
|
6ee3f318f8 |
@@ -6,6 +6,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- '1.x'
|
- '1.x'
|
||||||
- '2.x'
|
- '2.x'
|
||||||
|
- '3.x'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 3.0.0 - 2022-11-26
|
||||||
|
This release replaces `stella-maris/clock` with `psr/clock`.
|
||||||
|
|
||||||
|
## 2.3.1 - 2022-11-25
|
||||||
|
This release reverts the change to implement `psr/clock` directly, to not break dependents who rely on `stella-maris/clock`
|
||||||
|
|
||||||
## 2.3.0 - 2022-11-25
|
## 2.3.0 - 2022-11-25
|
||||||
This release re-introduces support for PHP ^8.0 and implements the freshly released `psr/clock` (PSR-20) directly.
|
This release re-introduces support for PHP ^8.0 and implements the freshly released `psr/clock` (PSR-20) directly.
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ namespace Beste\Clock;
|
|||||||
|
|
||||||
use Beste\Clock;
|
use Beste\Clock;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use InvalidArgumentException;
|
|
||||||
use Psr\Clock\ClockInterface;
|
use Psr\Clock\ClockInterface;
|
||||||
|
|
||||||
final class WrappingClock implements Clock
|
final class WrappingClock implements Clock
|
||||||
@@ -25,11 +24,11 @@ final class WrappingClock implements Clock
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!method_exists($clock, 'now')) {
|
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)) {
|
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 {
|
$wrappedClock = new class($clock) implements ClockInterface {
|
||||||
@@ -40,13 +39,13 @@ final class WrappingClock implements Clock
|
|||||||
$this->clock = $clock;
|
$this->clock = $clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function now(): DateTimeImmutable
|
public function now(): \DateTimeImmutable
|
||||||
{
|
{
|
||||||
assert(method_exists($this->clock, 'now'));
|
assert(method_exists($this->clock, 'now'));
|
||||||
|
|
||||||
$now = $this->clock->now();
|
$now = $this->clock->now();
|
||||||
|
|
||||||
assert($now instanceof DateTimeImmutable);
|
assert($now instanceof \DateTimeImmutable);
|
||||||
|
|
||||||
return $now;
|
return $now;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user