add annotations
This commit is contained in:
parent
ecde79dfe5
commit
ece82c24a9
50
src/Annotation.php
Normal file
50
src/Annotation.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DavidBadura\Taskwarrior;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use JMS\Serializer\Annotation as JMS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author David Badura <d.a.badura@gmail.com>
|
||||||
|
*/
|
||||||
|
class Annotation
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
*/
|
||||||
|
private $description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Carbon
|
||||||
|
*
|
||||||
|
* @JMS\Type("Carbon")
|
||||||
|
*/
|
||||||
|
private $entry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $description
|
||||||
|
*/
|
||||||
|
public function setDescription($description)
|
||||||
|
{
|
||||||
|
$this->description = $description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Carbon
|
||||||
|
*/
|
||||||
|
public function getEntry()
|
||||||
|
{
|
||||||
|
return $this->entry;
|
||||||
|
}
|
||||||
|
}
|
47
src/Task.php
47
src/Task.php
@ -106,6 +106,13 @@ class Task
|
|||||||
*/
|
*/
|
||||||
private $until;
|
private $until;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Annotation[]
|
||||||
|
*
|
||||||
|
* @JMS\Type("array<DavidBadura\Taskwarrior\Annotation>")
|
||||||
|
*/
|
||||||
|
private $annotations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Carbon
|
* @var Carbon
|
||||||
*
|
*
|
||||||
@ -352,6 +359,46 @@ class Task
|
|||||||
$this->until = $this->parseDateTime($until);
|
$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
|
* @return Carbon
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user