Total Complexity | 7 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Coverage | 94.74% |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class Client implements HttpClient, HttpAsyncClient |
||
18 | { |
||
19 | /** |
||
20 | * React HTTP client. |
||
21 | * |
||
22 | * @var ReactBrowser |
||
23 | */ |
||
24 | private $client; |
||
25 | |||
26 | /** |
||
27 | * React event loop. |
||
28 | * |
||
29 | * @var LoopInterface |
||
30 | */ |
||
31 | private $loop; |
||
32 | |||
33 | /** |
||
34 | * Initialize the React client. |
||
35 | */ |
||
36 | 104 | public function __construct( |
|
37 | LoopInterface $loop = null, |
||
38 | ReactBrowser $client = null |
||
39 | ) { |
||
40 | 104 | if (null !== $client && null === $loop) { |
|
41 | throw new \RuntimeException('You must give a LoopInterface instance with the Client'); |
||
42 | } |
||
43 | |||
44 | 104 | $this->loop = $loop ?: ReactFactory::buildEventLoop(); |
|
45 | 104 | $this->client = $client ?: ReactFactory::buildHttpClient($this->loop); |
|
46 | 104 | } |
|
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | 51 | public function sendRequest(RequestInterface $request): ResponseInterface |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | 104 | public function sendAsyncRequest(RequestInterface $request) |
|
75 | } |
||
76 | } |
||
77 |