public function GetTaskHistory() { $chain = new \SplStack(); $added = array(); // If we traverse in order, then we preserve the order that tasks // made it to the TASK_FINISHED state, so long as we exclude // duplicates. foreach ($this->tasks as $task) { if ($task->state() == self::TASK_FINISHED && !in_array($task, $added)) { $chain->Unshift($task); $added[] = $task; } } return $chain; }