Response   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 1
dl 14
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 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
/**
4
 * Author: Nil Portugués Calderó <[email protected]>
5
 * Date: 7/27/15
6
 * Time: 11:46 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\Http\Message;
12
13
use NilPortugues\Api\Http\Message\AbstractResponse;
14
15
/**
16
 * Class Response.
17
 *
18
 * When an API call is successful, the JSend object is used as a simple envelope for the results, using the data key.
19
 */
20 View Code Duplication
class Response extends AbstractResponse
0 ignored issues
show
Duplication introduced by
This class 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...
21
{
22
    /**
23
     * @param string $content
24
     */
25
    public function __construct($content)
26
    {
27
        $this->response = parent::instance(
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (instance() instead of __construct()). Are you sure this is correct? If so, you might want to change this to $this->instance().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
28
            sprintf('{"status": "success", %s}', substr(substr($content, 1), 0, -1)),
29
            200,
30
            $this->headers
31
        );
32
    }
33
}
34