DataArraySerializer::null()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace NavJobs\Transmit\Serializers;
4
5
use League\Fractal\Resource\ResourceInterface;
6
use League\Fractal\Serializer\ArraySerializer as BaseArraySerializer;
7
8
class DataArraySerializer extends BaseArraySerializer
9
{
10
    /**
11
     * Serialize a collection.
12
     *
13
     * @param string $resourceKey
14
     * @param array  $data
15
     *
16
     * @return array
17
     */
18 View Code Duplication
    public function collection($resourceKey, array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        if ($resourceKey === false) {
21
            return $data;
22
        }
23
24
        return $resourceKey ? [$resourceKey => $data] : ['data' => $data];
25
    }
26
27
    /**
28
     * Serialize an item.
29
     *
30
     * @param string $resourceKey
31
     * @param array  $data
32
     *
33
     * @return array
34
     */
35 View Code Duplication
    public function item($resourceKey, array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        if ($resourceKey === false) {
38
            return $data;
39
        }
40
41
        return $resourceKey ? [$resourceKey => $data] : ['data' => $data];
42
    }
43
44
    /**
45
     * @return array
46
     */
47
    public function null()
48
    {
49
        return [
50
            null
51
        ];
52
    }
53
54
    /**
55
     * Serialize the meta.
56
     *
57
     * @param array $meta
58
     *
59
     * @return array
60
     */
61
    public function meta(array $meta)
62
    {
63
        if (empty($meta)) {
64
            return [];
65
        }
66
67
        return $meta;
68
    }
69
}
70