JsonResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 0 4 1
A decode() 0 4 1
1
<?php namespace KamranAhmed\Smasher;
2
3
use KamranAhmed\Smasher\Contracts\ResponseContract;
4
5
/**
6
 * JsonResponse
7
 *
8
 * Helps encoding and decoding arrays to JSON
9
 */
10
class JsonResponse implements ResponseContract
11
{
12
    /**
13
     * Formats the passed data/array to json
14
     * @param  array $data The data which is to be encoded
15
     * @return string
16
     */
17 2
    public function encode($data)
18
    {
19 2
        return json_encode($data);
20
    }
21
22
    /**
23
     * Decodes the passed string and creates array from it
24
     * @param  string $response The existing response which is to be decoded to array
25
     * @return array
26
     */
27 3
    public function decode($response)
28
    {
29 3
        return json_decode($response, true);
30
    }
31
}
32