1 | <?php |
||
26 | abstract class ResponseAbstract implements ResponseInterface{ |
||
27 | |||
28 | /** |
||
29 | * @var resource |
||
30 | */ |
||
31 | protected $curl; |
||
32 | |||
33 | /** |
||
34 | * @var \stdClass |
||
35 | */ |
||
36 | protected $curl_info; |
||
37 | |||
38 | /** |
||
39 | * @var \stdClass |
||
40 | */ |
||
41 | protected $response_headers; |
||
42 | |||
43 | /** |
||
44 | * @var \stdClass |
||
45 | */ |
||
46 | protected $response_error; |
||
47 | |||
48 | /** |
||
49 | * @var mixed |
||
50 | */ |
||
51 | protected $response_body; |
||
52 | |||
53 | /** |
||
54 | * Response constructor. |
||
55 | * |
||
56 | * @param resource $curl |
||
57 | * |
||
58 | * @throws \chillerlan\TinyCurl\ResponseException |
||
59 | */ |
||
60 | public function __construct($curl){ |
||
73 | |||
74 | /** |
||
75 | * @param string $property |
||
76 | * |
||
77 | * @return mixed |
||
78 | */ |
||
79 | public function __get($property){ |
||
101 | |||
102 | /** |
||
103 | * executes the cURL call, fills self::$response_body and calls self::getInfo() |
||
104 | */ |
||
105 | abstract protected function exec(); |
||
106 | |||
107 | /** |
||
108 | * @param resource $curl |
||
109 | * @param string $header_line |
||
110 | * |
||
111 | * @return int |
||
112 | * |
||
113 | * @link http://php.net/manual/function.curl-setopt.php CURLOPT_HEADERFUNCTION |
||
114 | */ |
||
115 | protected function headerLine(/** @noinspection PhpUnusedParameterInspection */$curl, $header_line){ |
||
131 | |||
132 | /** |
||
133 | * @return \stdClass |
||
134 | */ |
||
135 | protected function getBody(){ |
||
144 | |||
145 | /** |
||
146 | * |
||
147 | */ |
||
148 | protected function getInfo(){ |
||
161 | |||
162 | /** |
||
163 | * @param \stdClass $response_headers |
||
164 | * |
||
165 | * @return array |
||
166 | */ |
||
167 | protected function response_headers_array(\stdClass $response_headers):array { |
||
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.