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

NexusPHP / framework / 16868376028

02 Aug 2025 01:15PM UTC coverage: 100.0%. Remained the same
16868376028

push

github

paulbalandan
Remove use of deprecated `DATE_RFC7231` constant

1 of 1 new or added line in 1 file covered. (100.0%)

1176 of 1176 relevant lines covered (100.0%)

9.77 hits per line

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

100.0
/src/Nexus/Clock/InternalClock.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of the Nexus framework.
7
 *
8
 * (c) John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Nexus\Clock;
15

16
/**
17
 * A reference to the internal clock.
18
 *
19
 * This is primarily useful for mocking the clock in tests.
20
 * Classes should not use this class directly, but instead
21
 * use the `Clock` interface or the two traits `ClockAware`
22
 * and `ImmutableClockAware`.
23
 *
24
 * @internal
25
 */
26
final class InternalClock implements Clock
27
{
28
    private static ?Clock $internalClock;
29

30
    public function __construct(
31
        private readonly ?Clock $innerClock = null,
32
        private ?\DateTimeZone $timezone = null,
33
    ) {}
8✔
34

35
    /**
36
     * Returns the current internal clock.
37
     *
38
     * If no internal clock has been set, a new instance of SystemClock
39
     * will be created with the UTC timezone.
40
     */
41
    public static function getCurrent(): Clock
42
    {
43
        self::$internalClock ??= new SystemClock('UTC');
14✔
44

45
        return self::$internalClock;
14✔
46
    }
47

48
    /**
49
     * Sets the internal clock.
50
     */
51
    public static function set(?Clock $clock): void
52
    {
53
        self::$internalClock = $clock;
14✔
54
    }
55

56
    #[\Override]
57
    public function now(): \DateTimeImmutable
58
    {
59
        $now = ($this->innerClock ?? self::getCurrent())->now();
8✔
60

61
        if (null !== $this->timezone) {
8✔
62
            $now = $now->setTimezone($this->timezone);
4✔
63
        }
64

65
        return $now;
8✔
66
    }
67

68
    #[\Override]
69
    public function sleep(float|int $seconds): void
70
    {
71
        ($this->innerClock ?? self::getCurrent())->sleep($seconds);
8✔
72
    }
73
}
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