1: <?php
2:
3: namespace React\Socket;
4:
5: use React\Socket\ConnectorInterface;
6: use React\EventLoop\LoopInterface;
7: use React\Promise\Timer;
8:
9: final class TimeoutConnector implements ConnectorInterface
10: {
11: private $connector;
12: private $timeout;
13: private $loop;
14:
15: public function __construct(ConnectorInterface $connector, $timeout, LoopInterface $loop)
16: {
17: $this->connector = $connector;
18: $this->timeout = $timeout;
19: $this->loop = $loop;
20: }
21:
22: public function connect($uri)
23: {
24: return Timer\timeout($this->connector->connect($uri), $this->timeout, $this->loop);
25: }
26: }
27: