Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Commit

Permalink
some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed Jun 28, 2015
1 parent a26758d commit 7019d21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/TaskManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class TaskManager
*/
private $tasks = [];

/**
* @var Serializer
*/
private $serializer;

/**
* @param Taskwarrior $taskwarrior
*/
Expand Down Expand Up @@ -400,12 +405,16 @@ private function transformDate(\DateTime $dateTime = null)
*/
private function getSerializer()
{
if ($this->serializer) {
return $this->serializer;
}

$propertyNamingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());

$visitor = new JsonSerializationVisitor($propertyNamingStrategy);
$visitor->setOptions(JSON_UNESCAPED_UNICODE);

return SerializerBuilder::create()
return $this->serializer = SerializerBuilder::create()
->setPropertyNamingStrategy($propertyNamingStrategy)
->configureHandlers(function (HandlerRegistryInterface $registry) {
$registry->registerSubscribingHandler(new CarbonHandler());
Expand Down
5 changes: 5 additions & 0 deletions src/Taskwarrior.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Taskwarrior
* @param string $taskData
* @param array $rcOptions
* @param string $bin
* @throws TaskwarriorException
*/
public function __construct($taskrc = '~/.taskrc', $taskData = '~/.task', $rcOptions = [], $bin = 'task')
{
Expand All @@ -51,6 +52,10 @@ public function __construct($taskrc = '~/.taskrc', $taskData = '~/.task', $rcOpt
),
$rcOptions
);

if (version_compare($this->version(), '2.4.3') < 0) {
throw new TaskwarriorException(sprintf("Taskwarrior version %s isn't supported", $this->version()));
}
}

/**
Expand Down

0 comments on commit 7019d21

Please sign in to comment.