phpmyadmin/tests/unit/Clock/MockClock.php
Maurício Meneghini Fauth efa8ce431b
Introduce support for PSR-20 ClockInterface
Related to https://github.com/phpmyadmin/phpmyadmin/pull/20030

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
2026-01-19 19:22:53 -03:00

27 lines
531 B
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Clock;
use DateTimeImmutable;
use Psr\Clock\ClockInterface;
final class MockClock implements ClockInterface
{
public function __construct(public DateTimeImmutable $now)
{
}
public function now(): DateTimeImmutable
{
return clone $this->now;
}
/** @param non-empty-string $dateTime */
public static function from(string $dateTime = 'now'): ClockInterface
{
return new self(new DateTimeImmutable($dateTime));
}
}