LinkNormalizer::normalizeLink()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 7
ccs 1
cts 1
cp 1
crap 1
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