Response::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
rs 9.4286
cc 1
eloc 5
nc 1
nop 1
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