add QueryBuilder

This commit is contained in:
DavidBadura
2015-04-06 21:49:38 +00:00
parent 0ab45fae1f
commit a0ca517981
4 changed files with 206 additions and 47 deletions

View File

@@ -2,7 +2,6 @@
namespace DavidBadura\Taskwarrior;
use Carbon\Carbon;
use DavidBadura\Taskwarrior\Exception\TaskwarriorException;
use DavidBadura\Taskwarrior\Serializer\Handler\CarbonHandler;
use DavidBadura\Taskwarrior\Serializer\Handler\RecurringHandler;
@@ -113,7 +112,7 @@ class TaskManager
$this->tasks[$task->getUuid()] = $task;
}
return $this->sort($result);
return $result;
}
/**
@@ -216,6 +215,14 @@ class TaskManager
$this->tasks = [];
}
/**
* @return QueryBuilder
*/
public function createQueryBuilder()
{
return new QueryBuilder($this);
}
/**
* @param string|array $filter
* @return Task[]
@@ -291,26 +298,6 @@ class TaskManager
}
}
/**
* @param Task[] $tasks
* @return Task[]
*/
private function sort(array $tasks)
{
usort(
$tasks,
function (Task $a, Task $b) {
if (0 != $diff = $b->getUrgency() - $a->getUrgency()) {
return $diff;
}
return $a->getEntry() >= $b->getEntry() ? 1 : -1;
}
);
return $tasks;
}
/**
*
* @param Task $task