1 | <?php |
||
26 | class Builder |
||
27 | { |
||
28 | /** |
||
29 | * The services. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | private $services = []; |
||
34 | |||
35 | /** |
||
36 | * The options. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | private $options = []; |
||
41 | |||
42 | /** |
||
43 | * The http client. |
||
44 | * |
||
45 | * @var HttpClient |
||
46 | */ |
||
47 | private $httpClient; |
||
48 | |||
49 | /** |
||
50 | * The request factory. |
||
51 | * |
||
52 | * @var RequestFactory |
||
53 | */ |
||
54 | private $requestFactory; |
||
55 | |||
56 | /** |
||
57 | * The cache item pool. |
||
58 | * |
||
59 | * @var CacheItemPoolInterface |
||
60 | */ |
||
61 | private $cacheItemPool; |
||
62 | |||
63 | /** |
||
64 | * Constructor. |
||
65 | * |
||
66 | * @param array $options |
||
67 | */ |
||
68 | public function __construct(array $options = []) |
||
72 | |||
73 | /** |
||
74 | * Adds a service. |
||
75 | * |
||
76 | * @param string $serviceName |
||
77 | * @param array $options |
||
78 | * |
||
79 | * @return Builder |
||
80 | */ |
||
81 | public function add($serviceName, array $options = []) |
||
82 | { |
||
83 | $this->services[$serviceName] = $options; |
||
84 | |||
85 | return $this; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Uses the given http client. |
||
90 | * |
||
91 | * @param HttpClient $httpClient |
||
92 | * |
||
93 | * @return Builder |
||
94 | */ |
||
95 | public function useHttpClient(HttpClient $httpClient) |
||
96 | { |
||
97 | $this->httpClient = $httpClient; |
||
98 | |||
99 | return $this; |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Uses the given request factory. |
||
104 | * |
||
105 | * @param RequestFactory $requestFactory |
||
106 | * |
||
107 | * @return Builder |
||
108 | */ |
||
109 | public function useRequestFactory(RequestFactory $requestFactory) |
||
110 | { |
||
111 | $this->requestFactory = $requestFactory; |
||
112 | |||
113 | return $this; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Uses the given cache item pool. |
||
118 | * |
||
119 | * @param CacheItemPoolInterface $cacheItemPool |
||
120 | * |
||
121 | * @return Builder |
||
122 | */ |
||
123 | public function useCacheItemPool(CacheItemPoolInterface $cacheItemPool) |
||
124 | { |
||
125 | $this->cacheItemPool = $cacheItemPool; |
||
126 | |||
127 | return $this; |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * Builds Swap. |
||
132 | * |
||
133 | * @return Swap |
||
134 | */ |
||
135 | public function build() |
||
149 | } |
||
150 |