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