Conditions | 4 |
Paths | 4 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
30 | public function normalizeLink(string $path, $object, NormalizerContextInterface $context) |
||
31 | { |
||
32 | $callback = $this->callback; |
||
33 | |||
34 | $link = $callback($path, $object, $context); |
||
35 | 3 | ||
36 | if (null === $link) { |
||
37 | 3 | @trigger_error( |
|
38 | sprintf( |
||
39 | 3 | 'If a link should not be serialized under certain conditions, use a "%s" instead', |
|
40 | PolicyInterface::class |
||
41 | 3 | ), |
|
42 | 1 | E_USER_DEPRECATED |
|
43 | 1 | ); |
|
44 | 1 | ||
45 | 1 | return null; |
|
46 | } |
||
47 | 1 | ||
48 | if (!$link instanceof LinkInterface) { |
||
49 | $type = is_object($link) ? get_class($link) : gettype($link); |
||
50 | 1 | ||
51 | throw SerializerLogicException::createInvalidLinkTypeReturned($path, $type); |
||
52 | } |
||
53 | 2 | ||
54 | 1 | return (new LinkNormalizer($link))->normalizeLink($path, $object, $context); |
|
55 | } |
||
57 |