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

Response   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 28.57 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 10
loc 35
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 10 10 2
A setContent() 0 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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