LinkNormalizer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 1
b 0
f 0
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