public function checkOverlap($task = null) { if ($task == null && $this->task == null) { throw new Task_Not_Found(); } if ($task == null) { $task = $this->task; } $goal = new Goal(); $goal->where(array("start <=" => $this->start, "end >=" => $this->end))->get_by_related($task); if ($goal->exists()) { throw new Goal_Overlap(); } }