Completed
Push — master ( cd7a0a...d0b3cc )
by
unknown
09:14
created

Response::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 3
cts 3
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 4
crap 2
1
<?php
2
3
namespace MediaMonks\RestApi\Response;
4
5
use Symfony\Component\HttpFoundation\Response as BaseResponse;
6
7
class Response extends BaseResponse
8
{
9
    /**
10
     * @param mixed $data    The response data
11
     * @param int   $status  The response status code
12
     * @param array $headers An array of response headers
13
     * @param bool  $json    If the data is already a JSON string
14
     */
15 View Code Duplication
    public function __construct($data = null, int $status = 200, array $headers = [], bool $json = false)
0 ignored issues
show
Unused Code introduced by
The parameter $json is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in 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...
16
    {
17
        parent::__construct('', $status, $headers);
18 13
19
        if (null === $data) {
20 13
            $data = new \ArrayObject();
21
        }
22 13
23
        $this->setContent($data);
24
    }
25
26
    /**
27
     * Sets the response content.
28
     *
29
     * We need to allow all sorts of content, not just the ones the regular Response setContent() allows
30
     *
31
     * @param mixed $content
32
     * @return Response
33
     * @api
34
     */
35
    public function setContent($content)
36
    {
37
        $this->content = $content;
38
39
        return $this;
40
    }
41
}
42