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