1<?php
2
3declare(strict_types=1);
4
5namespace Cron;
6
7use DateTimeInterface;
8
9/**
10 * CRON field interface.
11 */
12interface FieldInterface
13{
14    /**
15     * Check if the respective value of a DateTime field satisfies a CRON exp.
16     *
17     * @param DateTimeInterface $date  DateTime object to check
18     * @param string            $value CRON expression to test against
19     *
20     * @return bool Returns TRUE if satisfied, FALSE otherwise
21     */
22    public function isSatisfiedBy(DateTimeInterface $date, $value): bool;
23
24    /**
25     * When a CRON expression is not satisfied, this method is used to increment
26     * or decrement a DateTime object by the unit of the cron field.
27     *
28     * @param DateTimeInterface $date DateTime object to change
29     * @param bool $invert (optional) Set to TRUE to decrement
30     * @param string|null $parts (optional) Set parts to use
31     *
32     * @return FieldInterface
33     */
34    public function increment(DateTimeInterface &$date, $invert = false, $parts = null): FieldInterface;
35
36    /**
37     * Validates a CRON expression for a given field.
38     *
39     * @param string $value CRON expression value to validate
40     *
41     * @return bool Returns TRUE if valid, FALSE otherwise
42     */
43    public function validate(string $value): bool;
44}
45