Passed
Push — master ( f6f1d0...ed56e2 )
by Andrea
69:42 queued 61:17
created

JsonResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 28
ccs 9
cts 12
cp 0.75
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getEncodedResponse() 0 3 1
A __toString() 0 3 1
A getArrayResponse() 0 3 1
A __construct() 0 6 2
1
<?php
2
3
namespace Fi\CoreBundle\DependencyInjection;
4
5
class JsonResponse
6
{
7
    private $errcode = -123456789;
8
    private $message = '';
9
    private $parms = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
10
11 2
    public function __construct($errcode, $message, $parms = null)
12
    {
13 2
        $this->errcode = $errcode;
14 2
        $this->message = $message;
15 2
        if ($parms) {
16
            $this->parms = $parms;
17
        }
18 2
    }
19
20
    public function __toString()
21
    {
22
        return $this->getEncodedResponse();
23
    }
24
25 2
    public function getEncodedResponse()
26
    {
27 2
        return json_encode(array('errcode' => $this->errcode, 'message' => $this->message, 'parms' => $this->parms));
28
    }
29
30 2
    public function getArrayResponse()
31
    {
32 2
        return array('errcode' => $this->errcode, 'message' => $this->message, 'parms' => $this->parms);
33
    }
34
}
35