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\Response\ResponseException |
||
58 | */ |
||
59 | public function __construct($curl){ |
||
72 | |||
73 | /** |
||
74 | * Farewell. |
||
75 | */ |
||
76 | public function __destruct(){ |
||
81 | |||
82 | /** |
||
83 | * @param string $property |
||
84 | * |
||
85 | * @return mixed |
||
86 | * @throws \chillerlan\TinyCurl\Response\ResponseException |
||
87 | */ |
||
88 | public function __get($property){ |
||
108 | |||
109 | /** |
||
110 | * executes the cURL call, fills self::$response_body and calls self::getInfo() |
||
111 | */ |
||
112 | abstract protected function exec(); |
||
113 | |||
114 | /** |
||
115 | * @param resource $curl |
||
116 | * @param string $header_line |
||
117 | * |
||
118 | * @return int |
||
119 | * |
||
120 | * @link http://php.net/manual/function.curl-setopt.php CURLOPT_HEADERFUNCTION |
||
121 | */ |
||
122 | protected function headerLine(/** @noinspection PhpUnusedParameterInspection */$curl, $header_line){ |
||
139 | |||
140 | /** |
||
141 | * @return \stdClass |
||
142 | */ |
||
143 | protected function getBody(){ |
||
160 | |||
161 | /** |
||
162 | * |
||
163 | */ |
||
164 | protected function getInfo(){ |
||
176 | |||
177 | } |
||
178 |
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.