DataArraySerializer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 38
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 9
    public function item($resourceKey, array $data)
38
    {
39 9
        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