taskList)) { return $this->taskList[$taskId]; } return null; } public function add(Task $task) { $taskId = (microtime(true) * 10000) . rand(100000, 999999); $task->setId($taskId); $this->taskList[$taskId] = $task; return $task; } public function search(array $filterTask, $rows = null, $page = null, $sortBy = null, $sortOrder = null) { $taskList = array_filter($this->taskList, function ($elem) use ($filterTask) { /** * @var $elem Task */ if (isset($filterTask['status'])) { $result = ($elem->getStatus() === $filterTask['status']); } else { $result = ($elem->getStatus() !== Task::STATUS_ARCHIVED); } if (isset($filterTask['type'])) { $result = ($elem->getType() === $filterTask['type']); } if (isset($filterTask['owner'])) { $result = ($elem->getOwner() === $filterTask['owner']); } if (isset($filterTask['label'])) { $result = (strpos(strtolower($filterTask['label']), strtotime($elem->getLabel())) !== false); } return $result; }); return new TaskList($taskList); } public function has($taskId) { return !is_null($this->get($taskId)); } public function update($taskId, $status) { $task = $this->get($taskId); if (!is_null($task)) { $task->setStatus($status); return true; } return false; } public function setReport($taskId, \common_report_Report $report) { $task = $this->get($taskId); if (!is_null($task)) { $task->setReport($report); return true; } return false; } public function count(array $params) { return count($this->search($params)); } public function getAll() { return $this->taskList; } }