RawResponse::__call()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 6
1
<?php
2
3
namespace Trucker\Responses;
4
5
/**
6
 * Result class returned from Trucker when
7
 * a raw request is initiated.
8
 *
9
 * @author Alessandro Manno <[email protected]>
10
 */
11
class RawResponse extends BaseResponse
12
{
13
    /**
14
     * Response object.
15
     *
16
     * @var Response
17
     */
18
    protected $response;
19
20
    /**
21
     * Var to hold any errors returned.
22
     *
23
     * @var array
24
     */
25
    private $errors;
26
27
    /**
28
     * Var to tell if the request was successful.
29
     *
30
     * @var bool
31
     */
32
    public $success = false;
33
34
    /**
35
     * Constructor.
36
     *
37
     * @param bool     $successful
38
     * @param Response $response
39
     * @param array    $errors
40
     */
41 7
    public function __construct($successful = false, Response $response = null, array $errors = [])
42
    {
43 7
        $this->success = $successful;
44 7
        $this->errors = $errors;
45
46 7
        parent::__construct($response);
47 7
    }
48
49
    /**
50
     * Magic function to pass methods not found
51
     * on this class down to the Trucker\Responses\Response
52
     * object that is being wrapped.
53
     *
54
     * @param string $method name of called method
55
     * @param array  $args   arguments to the method
56
     *
57
     * @return mixed
58
     */
59 View Code Duplication
    public function __call($method, $args)
0 ignored issues
show
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...
60
    {
61
        if (!method_exists($this, $method)) {
62
            return call_user_func_array(
63
                [$this->response, $method],
64
                $args
65
            );
66
        }
67
        // @codeCoverageIgnoreStart
68
    }
69
70
    // @codeCoverageIgnoreEnd
71
72
    /**
73
     * Getter for errors.
74
     *
75
     * @return array
76
     */
77 1
    public function errors()
78
    {
79 1
        return $this->errors;
80
    }
81
82
    /**
83
     * Getter for response.
84
     *
85
     * @return mixed
86
     */
87 1
    public function response()
88
    {
89 1
        return $this->response->parseResponseStringToObject();
90
    }
91
92
    /**
93
     * @return Response
94
     */
95 1
    public function getResponse()
96
    {
97 1
        return $this->response;
98
    }
99
}
100