Skip to content

Commit

Permalink
Rename CarbonNormalizer to denormalizer as only denormalization happe…
Browse files Browse the repository at this point in the history
…ns (#5)
  • Loading branch information
tigitz authored Feb 5, 2021
1 parent 16491cc commit 08ea228
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 50 deletions.
26 changes: 26 additions & 0 deletions src/Normalizer/CarbonDenormalizer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Morrislaptop\PopoFactory\Normalizer;

use Carbon\Carbon;
use Carbon\CarbonInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;

class CarbonDenormalizer implements DenormalizerInterface
{
/**
* @inheritDoc
*/
public function denormalize($data, string $type, string $format = null, array $context = [])
{
return new Carbon($data);
}

/**
* @inheritDoc
*/
public function supportsDenormalization($data, string $type, string $format = null)
{
return is_a($type, CarbonInterface::class, true);
}
}
48 changes: 0 additions & 48 deletions src/Normalizer/CarbonNormalizer.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/PopoFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Morrislaptop\PopoFactory;

use Morrislaptop\PopoFactory\Normalizer\CarbonNormalizer;
use Morrislaptop\PopoFactory\Normalizer\CarbonDenormalizer;
use ReflectionClass;
use ReflectionProperty;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
Expand Down Expand Up @@ -41,7 +41,7 @@ public function __construct(string $dataTransferObjectClass, Serializer $seriali
{
$this->dataTransferObjectClass = $dataTransferObjectClass;
$this->serializer = $serializer ?: new Serializer([
new CarbonNormalizer,
new CarbonDenormalizer,
new DateTimeNormalizer,
new ArrayDenormalizer,
new ObjectNormalizer,
Expand Down

0 comments on commit 08ea228

Please sign in to comment.