JSendTransformer::serialization()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 11

Duplication

Lines 8
Ratio 42.11 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 19
rs 9.4286
cc 3
eloc 11
nc 4
nop 1
1
<?php
2
3
/**
4
 * Author: Nil Portugués Calderó <[email protected]>
5
 * Date: 7/18/15
6
 * Time: 2:26 PM.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace NilPortugues\Api\JSend;
12
13
use NilPortugues\Api\Json\JsonTransformer;
14
15
/**
16
 * Class JsonTransformer.
17
 */
18
class JSendTransformer extends JsonTransformer
19
{
20
    /**
21
     * @param $value
22
     *
23
     * @return mixed
24
     */
25
    protected function serialization($value)
26
    {
27
        $value = parent::serialization($value);
28
        $data = [];
29
30 View Code Duplication
        if (!empty($value[self::META_KEY])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
31
            $data[self::META_KEY] = $value[self::META_KEY];
32
            unset($value[self::META_KEY]);
33
        }
34
35 View Code Duplication
        if (!empty($value[self::LINKS])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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
            $data[self::LINKS] = $value[self::LINKS];
37
            unset($value[self::LINKS]);
38
        }
39
40
        $data = array_merge(['data' => $value], $data);
41
42
        return $data;
43
    }
44
}
45