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

DataArraySerializer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A collection() 0 4 1
A item() 0 4 1
A null() 0 4 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