1 | <?php |
||
16 | class PluginClient implements HttpClient, HttpAsyncClient |
||
17 | { |
||
18 | /** |
||
19 | * An HTTP async client. |
||
20 | * |
||
21 | * @var HttpAsyncClient |
||
22 | */ |
||
23 | protected $client; |
||
24 | |||
25 | /** |
||
26 | * The plugin chain. |
||
27 | * |
||
28 | * @var Plugin[] |
||
29 | */ |
||
30 | protected $plugins; |
||
31 | |||
32 | /** |
||
33 | * A list of options. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $options; |
||
38 | |||
39 | /** |
||
40 | * @param HttpClient|HttpAsyncClient $client |
||
41 | * @param Plugin[] $plugins |
||
42 | * @param array $options |
||
43 | * |
||
44 | * @throws \RuntimeException if client is not an instance of HttpClient or HttpAsyncClient |
||
45 | */ |
||
46 | public function __construct($client, array $plugins = [], array $options = []) |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | public function sendRequest(RequestInterface $request) |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | public function sendAsyncRequest(RequestInterface $request) |
||
79 | |||
80 | /** |
||
81 | * Configure the plugin client. |
||
82 | * |
||
83 | * @param array $options |
||
84 | * |
||
85 | * @return array |
||
86 | */ |
||
87 | protected function configure(array $options = []) |
||
96 | |||
97 | /** |
||
98 | * @param Plugin[] $pluginList |
||
99 | * |
||
100 | * @return callable |
||
101 | */ |
||
102 | private function createPluginChain($pluginList) |
||
133 | } |
||
134 |