LinkNormalizer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 26
ccs 4
cts 4
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalizeLink() 0 7 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization\Normalizer;
6
7
use Chubbyphp\Serialization\SerializerLogicException;
8
use Psr\Link\LinkInterface;
9
10
final class LinkNormalizer implements LinkNormalizerInterface
11
{
12
    /**
13
     * @var LinkInterface
14
     */
15
    private $link;
16
17
    public function __construct(LinkInterface $link)
18
    {
19
        $this->link = $link;
20 1
    }
21
22 1
    /**
23 1
     * @param object|mixed $object
24
     *
25
     * @throws SerializerLogicException
26
     *
27
     * @return array|null
28
     */
29
    public function normalizeLink(string $path, $object, NormalizerContextInterface $context)
30
    {
31
        return [
32
            'href' => $this->link->getHref(),
33
            'templated' => $this->link->isTemplated(),
34 1
            'rel' => $this->link->getRels(),
35
            'attributes' => $this->link->getAttributes(),
36
        ];
37 1
    }
38
}
39