1 | <?php |
||
44 | class SecondsField extends AbstractField |
||
45 | { |
||
46 | |||
47 | /** |
||
48 | * Check if the respective value of a DateTime field satisfies a CRON exp |
||
49 | * |
||
50 | * @param DateTime $date DateTime object to check |
||
51 | * @param string $value CRON expression to test against |
||
52 | * |
||
53 | * @return bool Returns TRUE if satisfied, FALSE otherwise |
||
54 | */ |
||
55 | 55 | public function isSatisfiedBy(DateTime $date, $value) |
|
59 | |||
60 | /** |
||
61 | * When a CRON expression is not satisfied, this method is used to increment |
||
62 | * or decrement a DateTime object by the unit of the cron field |
||
63 | * |
||
64 | * @param DateTime $date DateTime object to change |
||
65 | * @param bool $invert (optional) Set to TRUE to decrement |
||
66 | * |
||
67 | * @return FieldInterface |
||
68 | */ |
||
69 | 5 | public function increment(DateTime $date, $invert = false) |
|
70 | { |
||
71 | 5 | if ($invert) { |
|
72 | 2 | $date->modify('-1 second'); |
|
73 | } else { |
||
74 | 4 | $date->modify('+1 second'); |
|
75 | } |
||
76 | |||
77 | 5 | return $this; |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * Validates a CRON expression for a given field |
||
82 | * |
||
83 | * @param string $value CRON expression value to validate |
||
84 | * |
||
85 | * @return bool Returns TRUE if valid, FALSE otherwise |
||
86 | */ |
||
87 | 56 | public function validate($value) |
|
91 | } |
||
92 |