DocumentDataNormalizer::supportsNormalization()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\XApi\Serializer\Symfony\Normalizer;
13
14
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
15
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
16
use Xabbuh\XApi\Model\DocumentData;
17
18
/**
19
 * Normalizes and denormalizes xAPI statement documents.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 */
23
final class DocumentDataNormalizer implements DenormalizerInterface, NormalizerInterface
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function normalize($object, $format = null, array $context = array())
29
    {
30
        if (!$object instanceof DocumentData) {
31
            return null;
32
        }
33
34
        return $object->getData();
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function supportsNormalization($data, $format = null)
41
    {
42
        return $data instanceof DocumentData;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function denormalize($data, $class, $format = null, array $context = array())
49
    {
50
        return new DocumentData($data);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function supportsDenormalization($data, $type, $format = null)
57
    {
58
        return 'Xabbuh\XApi\Model\DocumentData' === $type;
59
    }
60
}
61