1 | <?php |
||
17 | final class Builder |
||
18 | { |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $endpoint; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $username; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | private $password; |
||
33 | |||
34 | /** |
||
35 | * @var \Http\Client\HttpClient |
||
36 | */ |
||
37 | private $httpClient; |
||
38 | |||
39 | /** |
||
40 | * @var \Http\Message\MessageFactory |
||
41 | */ |
||
42 | private $messageFactory; |
||
43 | |||
44 | /** |
||
45 | * @var \Http\Message\UriFactory |
||
46 | */ |
||
47 | private $uriFactory; |
||
48 | |||
49 | /** |
||
50 | * @var array |
||
51 | */ |
||
52 | private $pluginsAppend = []; |
||
53 | |||
54 | /** |
||
55 | * @var array |
||
56 | */ |
||
57 | private $pluginsPrepend = []; |
||
58 | |||
59 | /** |
||
60 | * Builder constructor. |
||
61 | * |
||
62 | * @param \Http\Client\HttpClient|null $httpClient |
||
63 | * @param \Http\Message\UriFactory|null $uriFactory |
||
64 | * |
||
65 | * @throws \Http\Discovery\Exception\NotFoundException |
||
66 | */ |
||
67 | public function __construct( |
||
74 | |||
75 | /** |
||
76 | * Create HTTP client with specified plugins |
||
77 | * |
||
78 | * @return \Http\Client\Common\PluginClient |
||
79 | * |
||
80 | * @throws \InvalidArgumentException |
||
81 | * @throws \RuntimeException |
||
82 | */ |
||
83 | public function createConfiguredClient() |
||
101 | |||
102 | /** |
||
103 | * Add endpoint to client |
||
104 | * |
||
105 | * @param string $endpoint |
||
106 | * |
||
107 | * @return $this |
||
108 | */ |
||
109 | public function withEndpoint($endpoint) |
||
115 | |||
116 | /** |
||
117 | * Add username to client |
||
118 | * |
||
119 | * @param string $username |
||
120 | * |
||
121 | * @return $this |
||
122 | */ |
||
123 | public function withUsername($username) |
||
129 | |||
130 | /** |
||
131 | * Add password to client |
||
132 | * |
||
133 | * @param string $password |
||
134 | * |
||
135 | * @return $this |
||
136 | */ |
||
137 | public function withPassword($password) |
||
143 | |||
144 | /** |
||
145 | * Add username and password to client |
||
146 | * |
||
147 | * @param string $username |
||
148 | * @param string $password |
||
149 | * |
||
150 | * @return $this |
||
151 | */ |
||
152 | public function withCredentials($username, $password) |
||
158 | |||
159 | /** |
||
160 | * Add plugins to client after it has been configured |
||
161 | * |
||
162 | * @param \Http\Client\Common\Plugin|\Http\Client\Common\Plugin[] ...$plugins |
||
163 | * |
||
164 | * @return $this |
||
165 | */ |
||
166 | public function appendPlugin(Plugin ...$plugins) |
||
174 | |||
175 | /** |
||
176 | * Add plugins to client before it has been configured |
||
177 | * |
||
178 | * @param \Http\Client\Common\Plugin|\Http\Client\Common\Plugin[] ...$plugins |
||
179 | * |
||
180 | * @return $this |
||
181 | */ |
||
182 | public function prependPlugin(Plugin ...$plugins) |
||
192 | } |
||
193 |