Passed
Pull Request — master (#15)
by
unknown
02:36
created

LinkNormalizer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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
    /**
18
     * @param LinkInterface $link
19
     */
20 1
    public function __construct(LinkInterface $link)
21
    {
22 1
        $this->link = $link;
23 1
    }
24
25
    /**
26
     * @param string                     $path
27
     * @param object|mixed               $object
28
     * @param NormalizerContextInterface $context
29
     *
30
     * @return array|null
31
     *
32
     * @throws SerializerLogicException
33
     */
34 1
    public function normalizeLink(string $path, $object, NormalizerContextInterface $context)
35
    {
36
        return [
37 1
            'href' => $this->link->getHref(),
38 1
            'templated' => $this->link->isTemplated(),
39 1
            'rel' => $this->link->getRels(),
40 1
            'attributes' => $this->link->getAttributes(),
41
        ];
42
    }
43
}
44