/** * * @param string $token * @return false|\DateTime */ public function filter($token) { $date = Text::findDate($token); if (!empty($date) && $this->verify($date)) { return new DateTime("{$date['year']}-{$date['month']}-{$date['day']}"); } return false; }
/** * @return DateTime[] */ public function getDates() { // return the cached copy if (empty($this->dates)) { $getDateFunc = function ($sentence) { $date = Text::findDate($sentence); return new DateTime("{$date['year']}-{$date['month']}-{$date['day']}"); }; $this->dates = array_map($getDateFunc, $this->sentences); // re-index so nulls and offsets are correct. $this->dates = array_values(array_filter($this->dates)); } return $this->dates; }