fixedTime = new \DateTimeImmutable($fixedTime); } /** * {@inheritdoc} */ public function now(): \DateTimeImmutable { return $this->fixedTime; } /** * {@inheritdoc} */ public function yesterday(): \DateTimeImmutable { return $this->fixedTime->modify('-1 day'); } /** * {@inheritdoc} */ public function today(): \DateTimeImmutable { return $this->fixedTime->setTime(0, 0); } /** * {@inheritdoc} */ public function tomorrow(): \DateTimeImmutable { return $this->fixedTime->modify('+1 day'); } /** * {@inheritdoc} */ public function time(int $hour = 0, int $minute = 0, int $second = 0): \DateTimeImmutable { return $this->fixedTime->setTime($hour, $minute, $second); } /** * {@inheritdoc} */ public static function fromTimestamp(int $timestamp): \DateTimeImmutable { return (new \DateTimeImmutable())->setTimestamp($timestamp); } /** * {@inheritdoc} */ public static function fromString(string $datetime): \DateTimeImmutable { return new \DateTimeImmutable($datetime); } /** * Set the fixed time to a new value * * @param string $fixedTime Fixed time in format 'Y-m-d H:i:s' * @return self */ public function withFixedTime(string $fixedTime): self { $clone = clone $this; $clone->fixedTime = new \DateTimeImmutable($fixedTime); return $clone; } }