diff options
Diffstat (limited to 'vendor/ipl/scheduler/src/Contract')
-rw-r--r-- | vendor/ipl/scheduler/src/Contract/Frequency.php | 62 | ||||
-rw-r--r-- | vendor/ipl/scheduler/src/Contract/Task.php | 39 |
2 files changed, 101 insertions, 0 deletions
diff --git a/vendor/ipl/scheduler/src/Contract/Frequency.php b/vendor/ipl/scheduler/src/Contract/Frequency.php new file mode 100644 index 0000000..2235787 --- /dev/null +++ b/vendor/ipl/scheduler/src/Contract/Frequency.php @@ -0,0 +1,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; +} diff --git a/vendor/ipl/scheduler/src/Contract/Task.php b/vendor/ipl/scheduler/src/Contract/Task.php new file mode 100644 index 0000000..db09ddc --- /dev/null +++ b/vendor/ipl/scheduler/src/Contract/Task.php @@ -0,0 +1,39 @@ +<?php + +namespace ipl\Scheduler\Contract; + +use Ramsey\Uuid\UuidInterface; +use React\Promise\ExtendedPromiseInterface; + +interface Task +{ + /** + * Get the name of this task + * + * @return string + */ + public function getName(): string; + + /** + * Get unique identifier of this task + * + * @return UuidInterface + */ + public function getUuid(): UuidInterface; + + /** + * Get the description of this task + * + * @return ?string + */ + public function getDescription(): ?string; + + /** + * Run this tasks operations + * + * This commits the actions in a non-blocking fashion to the event loop and yields a deferred promise + * + * @return ExtendedPromiseInterface + */ + public function run(): ExtendedPromiseInterface; +} |