1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
DelayParam.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
10
12{
16 public function __construct(public readonly int $delay)
17 {
18 }
19
20 public static function delayFor(\DateInterval $interval): self
21 {
22 $now = new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
23 $end = $now->add($interval);
24
25 return new self($end->getTimestamp() - $now->getTimestamp());
26 }
27
28 public static function delayUntil(Date $dateTime): self
29 {
30 return new self($dateTime->getTimestamp() - time());
31 }
32
33 public function applyTo(MessageBox $messageBox): MessageBox
34 {
35 if ($this->delay > 0)
36 {
37 $availableAt = new DateTime();
38
39 $availableAt->add(sprintf('+%d seconds', $this->delay));
40
41 $messageBox->setAvailableAt($availableAt);
42 }
43
44 return $messageBox;
45 }
46}
setAvailableAt(DateTime $availableAt)
Определения MessageBox.php:103
static delayFor(\DateInterval $interval)
Определения DelayParam.php:20
static delayUntil(Date $dateTime)
Определения DelayParam.php:28
__construct(public readonly int $delay)
Определения DelayParam.php:16
applyTo(MessageBox $messageBox)
Определения DelayParam.php:33
Определения date.php:9
getTimestamp()
Определения date.php:218