1 | <?php |
||
25 | final class ClientConfigurator |
||
26 | { |
||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $endpoint = 'https://sylius.com/api/v1'; |
||
31 | |||
32 | /** |
||
33 | * @var UriFactory |
||
34 | */ |
||
35 | private $uriFactory; |
||
36 | |||
37 | /** |
||
38 | * This is the client we use for actually sending the requests. |
||
39 | * |
||
40 | * @var HttpClient |
||
41 | */ |
||
42 | private $httpClient; |
||
43 | |||
44 | /** |
||
45 | * This is the client wrapping the $httpClient. |
||
46 | * |
||
47 | * @var PluginClient |
||
48 | */ |
||
49 | private $configuredClient; |
||
50 | |||
51 | /** |
||
52 | * @var Plugin[] |
||
53 | */ |
||
54 | private $prependPlugins = []; |
||
55 | |||
56 | /** |
||
57 | * @var Plugin[] |
||
58 | */ |
||
59 | private $appendPlugins = []; |
||
60 | |||
61 | /** |
||
62 | * True if we should create a new Plugin client at next request. |
||
63 | * @var bool |
||
64 | */ |
||
65 | private $configurationModified = true; |
||
66 | |||
67 | /** |
||
68 | * @param null|HttpClient $httpClient |
||
69 | * @param null|UriFactory $uriFactory |
||
70 | */ |
||
71 | public function __construct(HttpClient $httpClient = null, UriFactory $uriFactory = null) |
||
76 | |||
77 | /** |
||
78 | * @return HttpClient |
||
79 | */ |
||
80 | public function createConfiguredClient(): HttpClient |
||
98 | |||
99 | |||
100 | public function setEndpoint(string $endpoint): void |
||
104 | |||
105 | public function appendPlugin(Plugin ...$plugin): void |
||
112 | |||
113 | public function prependPlugin(Plugin ...$plugin): void |
||
121 | |||
122 | /** |
||
123 | * Remove a plugin by its fully qualified class name (FQCN). |
||
124 | */ |
||
125 | public function removePlugin(string $fqcn): void |
||
141 | } |
||
142 |