diff --git a/src/Task.php b/src/Task.php index e9eb6b6..08d5d71 100644 --- a/src/Task.php +++ b/src/Task.php @@ -14,6 +14,10 @@ class Task const STATUS_DELETED = 'deleted'; const STATUS_WAITING = 'waiting'; + const PRIORITY_LOW = 'L'; + const PRIORITY_MEDIUM = 'M'; + const PRIORITY_HIGH = 'H'; + /** * @var string * @@ -28,6 +32,13 @@ class Task */ private $description; + /** + * @var string + * + * @JMS\Type(name="string") + */ + private $priority; + /** * @var string * @@ -97,6 +108,22 @@ class Task $this->description = $description; } + /** + * @return string + */ + public function getPriority() + { + return $this->priority; + } + + /** + * @param string $priority + */ + public function setPriority($priority) + { + $this->priority = $priority; + } + /** * @return string */ diff --git a/src/TaskManager.php b/src/TaskManager.php index bdd5539..8ded8d5 100644 --- a/src/TaskManager.php +++ b/src/TaskManager.php @@ -191,6 +191,7 @@ class TaskManager [ 'description' => $task->getDescription(), 'project' => $task->getProject(), + 'priority' => $task->getPriority(), 'due' => $task->getDue() ? $task->getDue()->format('Ymd\THis\Z') : null, ], $task->getUuid() diff --git a/src/Taskwarrior.php b/src/Taskwarrior.php index 4152f13..7add7fe 100644 --- a/src/Taskwarrior.php +++ b/src/Taskwarrior.php @@ -66,6 +66,10 @@ class Taskwarrior $options[] = 'project:' . $params['project']; } + if (array_key_exists('priority', $params)) { + $options[] = 'priority:' . $params['priority']; + } + if (array_key_exists('description', $params)) { $options[] = $params['description']; } @@ -85,7 +89,7 @@ class Taskwarrior } /** - * @param $json + * @param string $json * @return string * @throws TaskwarriorException */ diff --git a/tests/TaskManagerTest.php b/tests/TaskManagerTest.php index 1581698..339206e 100644 --- a/tests/TaskManagerTest.php +++ b/tests/TaskManagerTest.php @@ -351,6 +351,28 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array('home', 'office'), $this->taskManager->projects()); } + public function testPriority() + { + $task1 = new Task(); + $task1->setDescription('foo1'); + $task1->setPriority(Task::PRIORITY_MEDIUM); + + $this->taskManager->save($task1); + $this->taskManager->clear(); + + $task1 = $this->taskManager->find($task1->getUuid()); + + $this->assertEquals(Task::PRIORITY_MEDIUM, $task1->getPriority()); + + $task1->setPriority(Task::PRIORITY_HIGH); + + $this->taskManager->save($task1); + $this->taskManager->clear(); + $task1 = $this->taskManager->find($task1->getUuid()); + + $this->assertEquals(Task::PRIORITY_HIGH, $task1->getPriority()); + } + /** * @param string $string * @return \DateTime