lazy validation
This commit is contained in:
parent
44274c6fc2
commit
c026f2b954
11
src/Task.php
11
src/Task.php
@ -270,16 +270,15 @@ class Task
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|Recurring $recur
|
* @param string|Recurring $recur
|
||||||
* @throws TaskwarriorException
|
|
||||||
*/
|
*/
|
||||||
public function setRecurring($recur)
|
public function setRecurring($recur)
|
||||||
{
|
{
|
||||||
if (is_string($recur)) {
|
if ($recur instanceof Recurring) {
|
||||||
$this->recur = new Recurring($recur);
|
|
||||||
} elseif ($recur instanceof Recurring) {
|
|
||||||
$this->recur = $recur;
|
$this->recur = $recur;
|
||||||
} elseif ($this->recur && is_null($recur)) {
|
} elseif ($recur) {
|
||||||
throw new TaskwarriorException('You cannot remove the recurrence from a recurring task.');
|
$this->recur = new Recurring($recur);
|
||||||
|
} else {
|
||||||
|
$this->recur = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,9 +205,14 @@ class TaskManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Task $task
|
* @param Task $task
|
||||||
|
* @throws TaskwarriorException
|
||||||
*/
|
*/
|
||||||
private function edit(Task $task)
|
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(
|
$this->taskwarrior->modify(
|
||||||
[
|
[
|
||||||
'description' => $task->getDescription(),
|
'description' => $task->getDescription(),
|
||||||
|
@ -541,6 +541,8 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->taskManager->save($task1);
|
$this->taskManager->save($task1);
|
||||||
|
|
||||||
$task1->setRecurring(null);
|
$task1->setRecurring(null);
|
||||||
|
|
||||||
|
$this->taskManager->save($task1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRecurringNull()
|
public function testRecurringNull()
|
||||||
|
Loading…
Reference in New Issue
Block a user