Total Complexity | 7 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Coverage | 90% |
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( |
||
42 | 'You must give a LoopInterface instance with the Client' |
||
43 | ); |
||
44 | } |
||
45 | |||
46 | 104 | $this->loop = $loop ?: ReactFactory::buildEventLoop(); |
|
47 | 104 | $this->client = $client ?: ReactFactory::buildHttpClient($this->loop); |
|
48 | 104 | } |
|
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | 51 | public function sendRequest(RequestInterface $request): ResponseInterface |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | 104 | public function sendAsyncRequest(RequestInterface $request) |
|
77 | } |
||
78 | } |
||
79 |