start = $start; $this->end = $end; } /** * @param mixed $value Value to match. * * @return boolean */ public function match($value) { if (! is_numeric($value) && ! is_int($value) && ! is_float($value) && ! is_string($value)) { $this->error = 'Can match only integers, float and datetime values'; return false; } $start = $this->start; $end = $this->end; if (DateConverter::can($value)) { // For string which represent date try to convert it into \DateTime // instances. try { $value = DateConverter::convert($value); $start = DateConverter::convert($start); $end = DateConverter::convert($end); $value->setTimezone($start->getTimezone()); } catch (\Exception $e) { $this->error = $e->getMessage(); return false; } } else { // For scalar types convert all values to the same type. $type = gettype($start); settype($value, $type); } return ($value >= $start) && ($value <= $end); } }