• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RikudouSage / DynamoDbCachePsr6 / 22776843842

06 Mar 2026 06:35PM UTC coverage: 99.211% (-0.2%) from 99.458%
22776843842

Pull #37

github

web-flow
Merge e96794afa into e612f9757
Pull Request #37: Chore: Replace clock

14 of 15 new or added lines in 4 files covered. (93.33%)

377 of 380 relevant lines covered (99.21%)

11.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/src/Helper/ClockHelper.php
1
<?php
2

3
namespace Rikudou\DynamoDbCache\Helper;
4

5
use DateTimeImmutable;
6
use Psr\Clock\ClockInterface as PsrClock;
7
use Rikudou\Clock\ClockInterface as RikudouClock;
8

9
/**
10
 * @internal
11
 */
12
final class ClockHelper
13
{
14
    public static function psrClock(RikudouClock|PsrClock|null $clock = null): PsrClock
15
    {
16
        if ($clock instanceof RikudouClock) {
61✔
NEW
17
            trigger_error(sprintf('%s is deprecated, use %s instead', RikudouClock::class, PsrClock::class), E_USER_DEPRECATED);
×
18
        }
19

20
        return new class($clock) implements PsrClock {
61✔
21
            public function __construct(
22
                private RikudouClock|PsrClock|null $clock = null,
23
            ) {
24
            }
61✔
25

26
            public function now(): DateTimeImmutable
27
            {
28
                if ($this->clock !== null) {
24✔
29
                    return DateTimeImmutable::createFromInterface($this->clock->now());
6✔
30
                }
31

32
                return new DateTimeImmutable();
20✔
33
            }
34
        };
61✔
35
    }
36

37
    public static function fixedTimeClock(DateTimeImmutable $now): PsrClock
38
    {
39
        return new class($now) implements PsrClock {
11✔
40
            public function __construct(
41
                private DateTimeImmutable $now,
42
            ) {
43
            }
11✔
44

45
            public function now(): DateTimeImmutable
46
            {
47
                return $this->now;
6✔
48
            }
49
        };
11✔
50
    }
51
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc