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 | protected $subdomain; |
||
37 | |||
38 | /** |
||
39 | * @param string $link |
||
40 | * @param array $fields |
||
41 | */ |
||
42 | 3 | public function performRequest($link, array $fields) |
|
63 | |||
64 | /** |
||
65 | * @return bool |
||
66 | */ |
||
67 | 4 | public function getResponse() |
|
68 | { |
||
69 | 4 | if (!$this->response) { |
|
70 | 1 | return false; |
|
71 | } |
||
72 | |||
73 | 3 | $this->encodeResponse(); |
|
74 | |||
75 | 3 | return $this->response; |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param $subdomain string |
||
80 | */ |
||
81 | 4 | public function setSubdomain($subdomain) |
|
85 | |||
86 | /** |
||
87 | * @return mixed |
||
88 | */ |
||
89 | 1 | public function getSubdomain() |
|
93 | |||
94 | /** |
||
95 | * Encoding response from json, throw exception in case of wrong http code |
||
96 | */ |
||
97 | 3 | protected function encodeResponse() |
|
109 | |||
110 | /** |
||
111 | * @return string |
||
112 | */ |
||
113 | 3 | protected function getCookiePath() |
|
117 | } |