From 9e278a9370e3b651a4a545c0c0c0c256088ed187 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 24 Jun 2016 08:50:57 -0400 Subject: Use BoardFormatter to generate the board --- app/Formatter/BoardTaskFormatter.php | 80 ++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 app/Formatter/BoardTaskFormatter.php (limited to 'app/Formatter/BoardTaskFormatter.php') diff --git a/app/Formatter/BoardTaskFormatter.php b/app/Formatter/BoardTaskFormatter.php new file mode 100644 index 00000000..d9500710 --- /dev/null +++ b/app/Formatter/BoardTaskFormatter.php @@ -0,0 +1,80 @@ +tasks = $tasks; + return $this; + } + + /** + * Set columnId + * + * @access public + * @param integer $columnId + * @return $this + */ + public function withColumnId($columnId) + { + $this->columnId = $columnId; + return $this; + } + + /** + * Set swimlaneId + * + * @access public + * @param integer $swimlaneId + * @return $this + */ + public function withSwimlaneId($swimlaneId) + { + $this->swimlaneId = $swimlaneId; + return $this; + } + + /** + * Apply formatter + * + * @access public + * @return array + */ + public function format() + { + return array_values(array_filter($this->tasks, array($this, 'filterTasks'))); + } + + /** + * Keep only tasks of the given column and swimlane + * + * @access public + * @param array $task + * @return bool + */ + public function filterTasks(array $task) + { + return $task['column_id'] == $this->columnId && $task['swimlane_id'] == $this->swimlaneId; + } +} -- cgit v1.2.3