refactor validation

This commit is contained in:
DavidBadura 2015-04-03 14:39:19 +00:00
parent c026f2b954
commit 014c986103
1 changed files with 13 additions and 4 deletions

View File

@ -44,6 +44,8 @@ class TaskManager
*/
public function save(Task $task)
{
$this->validate($task);
if (!$task->getUuid()) {
$this->add($task);
} else {
@ -209,10 +211,6 @@ class TaskManager
*/
private function edit(Task $task)
{
if ($task->isReccuring() && !$task->getRecurring()) {
throw new TaskwarriorException('You cannot remove the recurrence from a recurring task.');
}
$this->taskwarrior->modify(
[
'description' => $task->getDescription(),
@ -228,6 +226,17 @@ class TaskManager
);
}
/**
* @param Task $task
* @throws TaskwarriorException
*/
private function validate(Task $task)
{
if ($task->isReccuring() && !$task->getRecurring()) {
throw new TaskwarriorException('You cannot remove the recurrence from a recurring task.');
}
}
/**
* @param Task $old
* @param Task $new