Completed
Branch develop (7f369c)
by Nicolas
04:28
created

DateTimeNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 5 1
A supportsNormalization() 0 3 1
1
<?php
2
3
namespace App\Serializer\Normalizer;
4
5
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
6
7
/**
8
 * DateTimeNormalizer.
9
 */
10
class DateTimeNormalizer implements NormalizerInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 9
    public function normalize($object, $format = null, array $context = [])
16
    {
17
        /* @var \DateTime $object */
18
19 9
        return $object->format(\DateTime::ATOM);
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 16
    public function supportsNormalization($data, $format = null)
26
    {
27 16
        return $data instanceof \DateTime;
28
    }
29
}
30