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

NexusPHP / framework / 15768680547

27 May 2025 01:19PM UTC coverage: 100.0%. Remained the same
15768680547

push

github

paulbalandan
Add clock extension API for writing time-sensitive classes

30 of 30 new or added lines in 4 files covered. (100.0%)

988 of 988 relevant lines covered (100.0%)

7.0 hits per line

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

100.0
/src/Nexus/Clock/Extension/ImmutableClockAware.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\Extension;
15

16
use Nexus\Clock\InternalClock;
17
use Psr\Clock\ClockInterface;
18

19
/**
20
 * A trait to help write time-sensitive immutable classes.
21
 *
22
 * @property null|ClockInterface $clock
23
 */
24
trait ImmutableClockAware
25
{
26
    /**
27
     * Gets the current timestamp.
28
     */
29
    private function now(): int
30
    {
31
        $clock = $this->clock ?? InternalClock::getCurrent();
2✔
32

33
        return $clock->now()->getTimestamp();
2✔
34
    }
35
}
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