update recurring
This commit is contained in:
parent
fb3da0face
commit
6d13ee7d3a
@ -14,10 +14,10 @@ $tm = TaskManager::create();
|
|||||||
$task = new Task();
|
$task = new Task();
|
||||||
$task->setDescription('program this lib');
|
$task->setDescription('program this lib');
|
||||||
$task->setProject('hobby');
|
$task->setProject('hobby');
|
||||||
$task->setDue(new \DateTime('tomorrow'));
|
$task->setDue('tomorrow');
|
||||||
$task->setPriority(Task::PRIORITY_HIGH);
|
$task->setPriority(Task::PRIORITY_HIGH);
|
||||||
$task->addTag('next');
|
$task->addTag('next');
|
||||||
$task->setRecur(new Recurring(Recurring::DAILY));
|
$task->setRecurring(Recurring::DAILY);
|
||||||
|
|
||||||
$tm->save($task);
|
$tm->save($task);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class Recurring
|
|||||||
*/
|
*/
|
||||||
public function __construct($recurring)
|
public function __construct($recurring)
|
||||||
{
|
{
|
||||||
if ($this->isValid($recurring)) {
|
if (self::isValid($recurring)) {
|
||||||
$this->recurring = $recurring;
|
$this->recurring = $recurring;
|
||||||
} else {
|
} else {
|
||||||
throw new TaskwarriorException();
|
throw new TaskwarriorException();
|
||||||
@ -51,7 +51,7 @@ class Recurring
|
|||||||
* @param string $recur
|
* @param string $recur
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function isValid($recur)
|
public static function isValid($recur)
|
||||||
{
|
{
|
||||||
$refClass = new \ReflectionClass(__CLASS__);
|
$refClass = new \ReflectionClass(__CLASS__);
|
||||||
$constants = $refClass->getConstants();
|
$constants = $refClass->getConstants();
|
||||||
|
@ -263,7 +263,7 @@ class Task
|
|||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getRecur()
|
public function getRecurring()
|
||||||
{
|
{
|
||||||
return $this->recur;
|
return $this->recur;
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ class Task
|
|||||||
* @param string|Recurring $recur
|
* @param string|Recurring $recur
|
||||||
* @throws TaskwarriorException
|
* @throws TaskwarriorException
|
||||||
*/
|
*/
|
||||||
public function setRecur($recur)
|
public function setRecurring($recur)
|
||||||
{
|
{
|
||||||
if (is_string($recur)) {
|
if (is_string($recur)) {
|
||||||
$this->recur = new Recurring($recur);
|
$this->recur = new Recurring($recur);
|
||||||
|
@ -264,10 +264,10 @@ class TaskManager
|
|||||||
*/
|
*/
|
||||||
private function setValue(Task $task, $attr, $value)
|
private function setValue(Task $task, $attr, $value)
|
||||||
{
|
{
|
||||||
$reflectionClass = new \ReflectionClass('DavidBadura\Taskwarrior\Task');
|
$refClass = new \ReflectionClass('DavidBadura\Taskwarrior\Task');
|
||||||
$prop = $reflectionClass->getProperty($attr);
|
$refProp = $refClass->getProperty($attr);
|
||||||
$prop->setAccessible(true);
|
$refProp->setAccessible(true);
|
||||||
$prop->setValue($task, $value);
|
$refProp->setValue($task, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -512,7 +512,7 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$task1 = new Task();
|
$task1 = new Task();
|
||||||
$task1->setDescription('foo1');
|
$task1->setDescription('foo1');
|
||||||
$task1->setDue('tomorrow');
|
$task1->setDue('tomorrow');
|
||||||
$task1->setRecur('daily');
|
$task1->setRecurring('daily');
|
||||||
|
|
||||||
$this->taskManager->save($task1);
|
$this->taskManager->save($task1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user