1 | <?php |
||
14 | class KProxy implements GoogleProxyInterface |
||
15 | { |
||
16 | /** @var string $endpoint */ |
||
17 | protected $endpoint; |
||
18 | /** @var int $serverNumber */ |
||
19 | protected $serverNumber; |
||
20 | |||
21 | /** |
||
22 | * Constructor that initializes the proxy service in one of its servers, which go from 1 to 9 |
||
23 | * |
||
24 | * @param int $serverNumber |
||
25 | */ |
||
26 | public function __construct(int $serverNumber) |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | * @throws \GuzzleHttp\Exception\ServerException If the proxy was overused |
||
38 | * @throws \GuzzleHttp\Exception\ConnectException If the proxy is unavailable |
||
39 | */ |
||
40 | public function getHttpResponse(string $url): ResponseInterface |
||
52 | |||
53 | /** |
||
54 | * Accesses the main page of the kproxy.com server. This is mandatory. |
||
55 | * |
||
56 | * @param Client $httpClient |
||
57 | */ |
||
58 | private function accessMainPage(Client $httpClient): void |
||
62 | |||
63 | /** {@inheritdoc} */ |
||
64 | public function parseUrl(string $url): string |
||
82 | |||
83 | /** |
||
84 | * Sends the request to the proxy service that saves the info in session. After this we can redirect |
||
85 | * the user to the search results |
||
86 | * |
||
87 | * @param Client $httpClient |
||
88 | * @param string $url |
||
89 | */ |
||
90 | private function sendRequestToProxy(Client $httpClient, string $url): void |
||
103 | } |
||
104 |