1 | <?php |
||
14 | abstract class AbstractBridge |
||
15 | { |
||
16 | const SEARCH = '/search'; |
||
17 | const CLUSTER = '/cluster'; |
||
18 | const REFINEMENTS = '/refinements'; |
||
19 | const RESULTS_CLASS = 'GroupByInc\API\Model\Results'; |
||
20 | const REFINEMENTS_RESULT_CLASS = 'GroupByInc\API\Model\RefinementsResult'; |
||
21 | const HTTP = 'http://'; |
||
22 | const HTTPS = 'https://'; |
||
23 | const COLON = ':'; |
||
24 | const MAX_TRIES = 3; |
||
25 | const RETRY_TIMEOUT = 80000; |
||
26 | const DEFAULT_TIMEOUT = 30; |
||
27 | const DEFAULT_CONNECT_TIMEOUT = 15; |
||
28 | |||
29 | /** @var string */ |
||
30 | private $clientKey; |
||
31 | /** @var string */ |
||
32 | private $bridgeUrl; |
||
33 | /** @var string */ |
||
34 | private $bridgeUrlCluster; |
||
35 | /** @var string */ |
||
36 | private $bridgeRefinementsUrl; |
||
37 | /** @var Serializer */ |
||
38 | private $serializer; |
||
39 | /** @var int */ |
||
40 | private $timeout; |
||
41 | /** @var int */ |
||
42 | private $connectTimeout; |
||
43 | |||
44 | /** |
||
45 | * @param string $clientKey |
||
46 | * @param string $baseUrl |
||
47 | */ |
||
48 | function __construct($clientKey, $baseUrl) |
||
57 | |||
58 | /** |
||
59 | * @param Query $query |
||
60 | * |
||
61 | * @return mixed |
||
62 | */ |
||
63 | public function search($query) |
||
69 | |||
70 | /** |
||
71 | * @param Query $query |
||
72 | * @param string $navigationName |
||
73 | * |
||
74 | * @return mixed |
||
75 | */ |
||
76 | public function refinements($query, $navigationName) |
||
82 | |||
83 | /** |
||
84 | * @param string $url |
||
85 | * @param string $content |
||
86 | * @param string $class |
||
87 | * |
||
88 | * @return mixed |
||
89 | */ |
||
90 | private function query($url, $content, $class) |
||
127 | |||
128 | /** |
||
129 | * @param string $url |
||
130 | * @param string $content |
||
131 | * @param int $tries |
||
132 | * |
||
133 | * @return Response |
||
134 | */ |
||
135 | protected function execute($url, $content, $tries) |
||
146 | |||
147 | /** |
||
148 | * @param Response $response |
||
149 | * |
||
150 | * @return bool|string |
||
151 | */ |
||
152 | private function getContentEncoding($response) |
||
163 | |||
164 | private function deserialize($json, $class) |
||
174 | |||
175 | /** |
||
176 | * @param int $connectTimeout seconds |
||
177 | * @return $this |
||
178 | */ |
||
179 | public function setConnectTimeout($connectTimeout) |
||
184 | |||
185 | /** |
||
186 | * @param int $timeout seconds |
||
187 | * @return $this |
||
188 | */ |
||
189 | public function setTimeout($timeout) |
||
194 | |||
195 | } |
||
196 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.