add annotations

This commit is contained in:
DavidBadura
2015-02-08 15:44:41 +00:00
parent ecde79dfe5
commit ece82c24a9
2 changed files with 97 additions and 0 deletions

View File

@@ -106,6 +106,13 @@ class Task
*/
private $until;
/**
* @var Annotation[]
*
* @JMS\Type("array<DavidBadura\Taskwarrior\Annotation>")
*/
private $annotations;
/**
* @var Carbon
*
@@ -352,6 +359,46 @@ class Task
$this->until = $this->parseDateTime($until);
}
/**
* @return Annotation[]
*/
public function getAnnotations()
{
return $this->annotations;
}
/**
* @param Annotation[] $annotations
*/
public function setAnnotations(array $annotations = [])
{
$this->annotations = [];
foreach ($annotations as $annotation) {
$this->addAnnotation($annotation);
}
}
/**
* @param Annotation $annotation
*/
public function addAnnotation(Annotation $annotation)
{
if (!in_array($annotation, $this->annotations)) {
$this->annotations[] = $annotation;
}
}
/**
* @param Annotation $annotation
*/
public function removeAnnotation(Annotation $annotation)
{
if ($key = array_search($annotation, $this->annotations)) {
unset($this->annotations[$key]);
}
}
/**
* @return Carbon
*/