@@ 13-39 (lines=27) @@ | ||
10 | /** |
|
11 | * @author Tobias Nyholm <[email protected]> |
|
12 | */ |
|
13 | class ReactFactory implements ClientFactory |
|
14 | { |
|
15 | /** |
|
16 | * @var MessageFactory |
|
17 | */ |
|
18 | private $messageFactory; |
|
19 | ||
20 | public function __construct(MessageFactory $messageFactory) |
|
21 | { |
|
22 | $this->messageFactory = $messageFactory; |
|
23 | } |
|
24 | ||
25 | /** |
|
26 | * {@inheritdoc} |
|
27 | */ |
|
28 | public function createClient(array $config = []) |
|
29 | { |
|
30 | if (!class_exists('Http\Adapter\React\Client')) { |
|
31 | throw new \LogicException('To use the React adapter you need to install the "php-http/react-adapter" package.'); |
|
32 | } |
|
33 | ||
34 | return new Client($this->messageFactory); |
|
35 | } |
|
36 | } |
|
37 |
@@ 13-39 (lines=27) @@ | ||
10 | /** |
|
11 | * @author Tobias Nyholm <[email protected]> |
|
12 | */ |
|
13 | class SocketFactory implements ClientFactory |
|
14 | { |
|
15 | /** |
|
16 | * @var MessageFactory |
|
17 | */ |
|
18 | private $messageFactory; |
|
19 | ||
20 | public function __construct(MessageFactory $messageFactory) |
|
21 | { |
|
22 | $this->messageFactory = $messageFactory; |
|
23 | } |
|
24 | ||
25 | /** |
|
26 | * {@inheritdoc} |
|
27 | */ |
|
28 | public function createClient(array $config = []) |
|
29 | { |
|
30 | if (!class_exists('Http\Client\Socket\Client')) { |
|
31 | throw new \LogicException('To use the Socket client you need to install the "php-http/socket-client" package.'); |
|
32 | } |
|
33 | ||
34 | return new Client($this->messageFactory, $config); |
|
35 | } |
|
36 | } |
|
37 |