Completed
Push — master ( d9d1e2...b73c31 )
by Ruben
01:14
created

LayeredSerializer::format()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

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