SimpleCollectionSerializer::collection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Rexlabs\Smokescreen\Serializer;
4
5
use Rexlabs\Smokescreen\Pagination\CursorInterface;
6
use Rexlabs\Smokescreen\Pagination\PaginatorInterface;
7
8
/**
9
 * Serializer to return simple collections:
10
 * - Returns collections without nesting them under a "data" key
11
 * - Returns items without any nesting.
12
 * - Does not support pagination
13
 * - Does not support cursor
14
 */
15
class SimpleCollectionSerializer extends DefaultSerializer
16
{
17
    /**
18
     * Serialize a collection.
19
     * The data will NOT be nested under a "data" key.
20
     *
21
     * @param string $resourceKey
22
     * @param array  $data
23
     *
24
     * @return array
25
     */
26 1
    public function collection($resourceKey, array $data): array
27
    {
28 1
        return $data;
29
    }
30
31
    /**
32
     * Serialize the paginator.
33
     *
34
     * @param PaginatorInterface $paginator
35
     *
36
     * @return array
37
     */
38 1
    public function paginator(PaginatorInterface $paginator)
39
    {
40 1
        return [];
41
    }
42
43
    /**
44
     * Serialize the cursor.
45
     *
46
     * @param CursorInterface $cursor
47
     *
48
     * @return array
49
     */
50 1
    public function cursor(CursorInterface $cursor): array
51
    {
52 1
        return [];
53
    }
54
}
55