Skip to content

Commit

Permalink
Merge pull request #6 from lukadschaak/patch-1
Browse files Browse the repository at this point in the history
Enable handler also for Carbon::class and CarbonImmutable::class
  • Loading branch information
scott-davidjones authored Feb 26, 2021
2 parents b1dad0a + d30e5cf commit da788ef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/AutumnDev/JMS/CarbonHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use JMS\Serializer\JsonDeserializationVisitor;
use JMS\Serializer\XmlDeserializationVisitor;
use JMS\Serializer\Context;
use Carbon\CarbonImmutable;
use Carbon\Carbon;
use DateTimeImmutable;
use DateTimeZone;
Expand All @@ -36,8 +37,8 @@ public function __construct($defaultFormat = DateTime::ISO8601, $defaultTimezone
public static function getSubscribingMethods()
{
$methods = [];
$deserialisationTypes = ['Carbon', 'CarbonImmutable'];
$serialisationTypes = ['Carbon', 'CarbonImmutable'];
$deserialisationTypes = ['Carbon', 'CarbonImmutable', Carbon::class, CarbonImmutable::class];
$serialisationTypes = ['Carbon', 'CarbonImmutable', Carbon::class, CarbonImmutable::class];

foreach (['json', 'xml', 'yml'] as $format) {

Expand Down Expand Up @@ -129,4 +130,4 @@ private function isDataXmlNull($data): bool
$attributes = $data->attributes('xsi', true);
return isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true';
}
}
}

0 comments on commit da788ef

Please sign in to comment.