1 | <?php |
||
30 | class Server implements InternalClientInterface |
||
31 | { |
||
32 | |||
33 | const PROTOCOL = 'http'; |
||
34 | const SQL_PATH = '/_sql'; |
||
35 | |||
36 | /** |
||
37 | * @var HttpClient |
||
38 | */ |
||
39 | private $client; |
||
40 | |||
41 | private $opts = [ |
||
42 | 'headers' => [] |
||
43 | ]; |
||
44 | |||
45 | /** |
||
46 | * @param string $uri |
||
47 | * @param array $options |
||
48 | */ |
||
49 | public function __construct($uri, array $options) |
||
|
|||
50 | { |
||
51 | $uri = self::computeURI($uri); |
||
52 | $this->client = new HttpClient([ |
||
53 | 'base_uri' => $uri |
||
54 | ]); |
||
55 | } |
||
56 | |||
57 | 1 | public function setTimeout($timeout) |
|
58 | { |
||
59 | 1 | $this->opts['timeout'] = (float)$timeout; |
|
60 | 1 | } |
|
61 | |||
62 | public function setHttpBasicAuth($username, $passwd) |
||
63 | { |
||
64 | $this->opts['auth'] = [$username, $passwd]; |
||
65 | } |
||
66 | |||
67 | 1 | public function setHttpHeader($name, $value) |
|
68 | { |
||
69 | 1 | $this->opts['headers'][$name] = $value; |
|
70 | 1 | } |
|
71 | |||
72 | 1 | public function getServerInfo() |
|
77 | |||
78 | 1 | public function getServerVersion() |
|
79 | { |
||
80 | // TODO: Implement getServerVersion() method. |
||
81 | 1 | throw new UnsupportedException('Not yet implemented'); |
|
83 | |||
84 | /** |
||
85 | * Execute a HTTP/1.1 POST request with JSON body |
||
86 | * |
||
87 | * @param array $body |
||
88 | |||
89 | * @return ResponseInterface |
||
90 | * @throws RequestException When an error is encountered |
||
91 | */ |
||
92 | public function doRequest(array $body) |
||
97 | |||
98 | /** |
||
99 | * Compute a URI for usage with the HTTP client |
||
100 | * |
||
101 | * @param string $server A host:port string |
||
102 | * |
||
103 | * @return string An URI which can be used by the HTTP client |
||
104 | */ |
||
105 | 4 | private static function computeURI($server) |
|
109 | } |
||
110 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.