PaginatorNormalizer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 4 1
A supportsNormalization() 0 3 1
1
<?php
2
3
namespace Apie\PaginationPlugin\Normalizers;
4
5
use Pagerfanta\Pagerfanta;
6
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
7
use Symfony\Component\Serializer\SerializerAwareInterface;
8
use Symfony\Component\Serializer\SerializerAwareTrait;
9
10
class PaginatorNormalizer implements NormalizerInterface, SerializerAwareInterface
11
{
12
    use SerializerAwareTrait;
13
14
    public function normalize($object, $format = null, array $context = [])
15
    {
16
        /** @var Pagerfanta $object */
17
        return $this->serializer->normalize($object->getCurrentPageResults(), $format, $context);
18
    }
19
20
    public function supportsNormalization($data, $format = null)
21
    {
22
        return $data instanceof Pagerfanta;
23
    }
24
}
25