1 | <?php |
||
25 | abstract class ResponseAbstract implements ResponseInterface{ |
||
26 | |||
27 | /** |
||
28 | * @var resource |
||
29 | */ |
||
30 | protected $curl; |
||
31 | |||
32 | /** |
||
33 | * @var \stdClass |
||
34 | */ |
||
35 | protected $curl_info; |
||
36 | |||
37 | /** |
||
38 | * @var \stdClass |
||
39 | */ |
||
40 | protected $response_headers; |
||
41 | |||
42 | /** |
||
43 | * @var \stdClass |
||
44 | */ |
||
45 | protected $response_error; |
||
46 | |||
47 | /** |
||
48 | * @var mixed |
||
49 | */ |
||
50 | protected $response_body; |
||
51 | |||
52 | /** |
||
53 | * Response constructor. |
||
54 | * |
||
55 | * @param resource $curl |
||
56 | * |
||
57 | * @throws \chillerlan\TinyCurl\ResponseException |
||
58 | */ |
||
59 | public function __construct($curl){ |
||
72 | |||
73 | /** |
||
74 | * @param string $property |
||
75 | * |
||
76 | * @return mixed |
||
77 | */ |
||
78 | public function __get($property){ |
||
98 | |||
99 | /** |
||
100 | * executes the cURL call, fills self::$response_body and calls self::getInfo() |
||
101 | */ |
||
102 | abstract protected function exec(); |
||
103 | |||
104 | /** |
||
105 | * @param resource $curl |
||
106 | * @param string $header_line |
||
107 | * |
||
108 | * @return int |
||
109 | * |
||
110 | * @link http://php.net/manual/function.curl-setopt.php CURLOPT_HEADERFUNCTION |
||
111 | */ |
||
112 | protected function headerLine(/** @noinspection PhpUnusedParameterInspection */$curl, $header_line){ |
||
128 | |||
129 | /** |
||
130 | * @return \stdClass |
||
131 | */ |
||
132 | protected function getBody(){ |
||
149 | |||
150 | /** |
||
151 | * |
||
152 | */ |
||
153 | protected function getInfo(){ |
||
166 | |||
167 | } |
||
168 |
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@return
doc comment to communicate to implementors of these methods what they are expected to return.