SimpleCollectionSerializer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 38
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A paginator() 0 3 1
A cursor() 0 3 1
A collection() 0 3 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