LayeredExtendedLinkSerializer::format()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\ResourceLinks\Serializers;
4
5
use Spatie\ResourceLinks\LinkContainer;
6
7
class LayeredExtendedLinkSerializer implements Serializer
8
{
9
    public function format(LinkContainer $linkContainer): array
10
    {
11
        $format = [
12
            $linkContainer->name => [
13
                'method' => $linkContainer->method,
14
                'action' => $linkContainer->action,
15
            ],
16
        ];
17
18
        return is_null($linkContainer->prefix)
19
            ? $format
20
            : [$linkContainer->prefix => $format];
21
    }
22
}
23