1 | <?php |
||
10 | class RequestHandler |
||
11 | { |
||
12 | /** |
||
13 | * @var |
||
14 | */ |
||
15 | protected $response; |
||
16 | |||
17 | /** |
||
18 | * @var integer |
||
19 | */ |
||
20 | protected $httpCode; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $httpErrors = [ |
||
26 | 301 => 'Moved permanently', |
||
27 | 400 => 'Bad request', |
||
28 | 401 => 'Unauthorized', |
||
29 | 403 => 'Forbidden', |
||
30 | 404 => 'Not found', |
||
31 | 500 => 'Internal server error', |
||
32 | 502 => 'Bad gateway', |
||
33 | 503 => 'Service unavailable' |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $successHttpCodes = [ |
||
40 | 200, 204 |
||
41 | ]; |
||
42 | |||
43 | protected $subdomain; |
||
44 | |||
45 | /** |
||
46 | * @param string $link |
||
47 | * @param array $fields |
||
48 | */ |
||
49 | 3 | public function performRequest($link, array $fields) |
|
70 | |||
71 | /** |
||
72 | * @return bool |
||
73 | */ |
||
74 | 4 | public function getResponse() |
|
84 | |||
85 | /** |
||
86 | * @param $subdomain string |
||
87 | */ |
||
88 | 4 | public function setSubdomain($subdomain) |
|
92 | |||
93 | /** |
||
94 | * @return mixed |
||
95 | */ |
||
96 | 1 | public function getSubdomain() |
|
100 | |||
101 | /** |
||
102 | * Encoding response from json, throw exception in case of wrong http code |
||
103 | */ |
||
104 | 3 | protected function encodeResponse() |
|
116 | |||
117 | /** |
||
118 | * @return string |
||
119 | */ |
||
120 | 3 | protected function getCookiePath() |
|
124 | } |