1: <?php
2:
3: namespace Cron;
4:
5: 6: 7:
8: class YearField extends AbstractField
9: {
10: public function isSatisfiedBy(\DateTime $date, $value)
11: {
12: return $this->isSatisfied($date->format('Y'), $value);
13: }
14:
15: public function increment(\DateTime $date, $invert = false)
16: {
17: if ($invert) {
18: $date->modify('-1 year');
19: $date->setDate($date->format('Y'), 12, 31);
20: $date->setTime(23, 59, 0);
21: } else {
22: $date->modify('+1 year');
23: $date->setDate($date->format('Y'), 1, 1);
24: $date->setTime(0, 0, 0);
25: }
26:
27: return $this;
28: }
29:
30: public function validate($value)
31: {
32: return (bool) preg_match('/[\*,\/\-0-9]+/', $value);
33: }
34: }
35: