summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/scheduler/src/Contract/Frequency.php
blob: 2235787755d3b202af97e84f69d55b088f29d7cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

namespace ipl\Scheduler\Contract;

use DateTimeInterface;
use JsonSerializable;

interface Frequency extends JsonSerializable
{
    /** @var string Format for representing datetimes when serializing the frequency to JSON */
    public const SERIALIZED_DATETIME_FORMAT = 'Y-m-d\TH:i:s.ue';

    /**
     * Get whether the frequency is due at the specified time
     *
     * @param DateTimeInterface $dateTime
     *
     * @return bool
     */
    public function isDue(DateTimeInterface $dateTime): bool;

    /**
     * Get the next due date relative to the given time
     *
     * @param DateTimeInterface $dateTime
     *
     * @return DateTimeInterface
     */
    public function getNextDue(DateTimeInterface $dateTime): DateTimeInterface;

    /**
     * Get whether the specified time is beyond the frequency's expiry time
     *
     * @param DateTimeInterface $dateTime
     *
     * @return bool
     */
    public function isExpired(DateTimeInterface $dateTime): bool;

    /**
     * Get the start time of this frequency
     *
     * @return ?DateTimeInterface
     */
    public function getStart(): ?DateTimeInterface;

    /**
     * Get the end time of this frequency
     *
     * @return ?DateTimeInterface
     */
    public function getEnd(): ?DateTimeInterface;

    /**
     * Create frequency from its stored JSON representation previously encoded with {@see json_encode()}
     *
     * @param string $json
     *
     * @return $this
     */
    public static function fromJson(string $json): self;
}