Completed
Pull Request — master (#277)
by
unknown
24:56
created

DataArraySerializer::null()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the League\Fractal package.
5
 *
6
 * (c) Phil Sturgeon <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\Fractal\Serializer;
13
14
class DataArraySerializer extends ArraySerializer
15
{
16
    /**
17
     * Serialize a collection.
18
     *
19
     * @param string $resourceKey
20
     * @param array  $data
21
     *
22
     * @return array
23
     */
24 5
    public function collection($resourceKey, array $data)
25
    {
26 5
        return ['data' => $data];
27
    }
28
29
    /**
30
     * Serialize an item.
31
     *
32
     * @param string $resourceKey
33
     * @param array  $data
34
     *
35
     * @return array
36
     */
37 6
    public function item($resourceKey, array $data)
38
    {
39 6
        return ['data' => $data];
40
    }
41
42
    /**
43
     * Serialize null resource.
44
     *
45
     * @return array
46
     */
47 1
    public function null()
48
    {
49 1
        return ['data' => []];
50
    }
51
}
52