1 | <?php |
||
21 | abstract class AbstractClient implements ClientInterface |
||
22 | { |
||
23 | protected $host; |
||
24 | protected $port; |
||
25 | protected $username; |
||
26 | protected $password; |
||
27 | protected $lang; |
||
28 | protected $version; |
||
29 | protected $services; |
||
30 | protected $serviceExtensions; |
||
31 | protected $ssl; |
||
32 | protected $local_cert; |
||
33 | protected $ca_cert; |
||
34 | protected $pk_cert; |
||
35 | protected $passphrase; |
||
36 | protected $debug; |
||
37 | protected $connect_timeout; |
||
38 | protected $timeout; |
||
39 | protected $objectSpec; |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | * |
||
44 | * @see \AfriCC\EPP\ClientInterface::connect() |
||
45 | */ |
||
46 | abstract public function connect($newPassword = false); |
||
47 | |||
48 | abstract public function close(); |
||
49 | |||
50 | abstract protected function log($message); |
||
51 | |||
52 | /** |
||
53 | * Send frame to EPP server |
||
54 | * |
||
55 | * @param FrameInterface $frame Frame to send |
||
56 | * |
||
57 | * @throws Exception on send error |
||
58 | */ |
||
59 | abstract public function sendFrame(FrameInterface $frame); |
||
60 | |||
61 | /** |
||
62 | * Get response frame from EPP server (use after sendFrame) |
||
63 | * |
||
64 | * @throws Exception on frame receive error |
||
65 | * |
||
66 | * @return string raw XML of EPP Frame |
||
67 | */ |
||
68 | abstract public function getFrame(); |
||
69 | |||
70 | public function request(FrameInterface $frame) |
||
84 | |||
85 | public function __construct(array $config, ObjectSpec $objectSpec = null) |
||
105 | |||
106 | /** |
||
107 | * Get client's ObjectSpec |
||
108 | * |
||
109 | * @return ObjectSpec |
||
110 | */ |
||
111 | public function getObjectSpec() |
||
115 | |||
116 | /** |
||
117 | * Set client's ObjectSpec |
||
118 | * |
||
119 | * @param ObjectSpec $newObjectSpec |
||
120 | */ |
||
121 | public function setObjectSpec(ObjectSpec $newObjectSpec) |
||
125 | |||
126 | /** |
||
127 | * Get config value from config array if set (default otherwise) |
||
128 | * |
||
129 | * Basically, a simple null coallesce operator (since we need to support PHP 5.5) |
||
130 | * |
||
131 | * @param array $config |
||
132 | * @param string $key |
||
133 | * @param mixed $default |
||
134 | * |
||
135 | * @return mixed |
||
136 | */ |
||
137 | protected function getConfigDefault(array $config, string $key, $default = null) |
||
145 | |||
146 | /** |
||
147 | * Get config value from config array if set (default otherwise) |
||
148 | * |
||
149 | * special version for bool values |
||
150 | * |
||
151 | * @param array $config |
||
152 | * @param string $key |
||
153 | * @param mixed $default |
||
154 | * |
||
155 | * @return mixed |
||
156 | * |
||
157 | * @see AbstractClient::getConfigDefault |
||
158 | */ |
||
159 | protected function getConfigDefaultBool(array $config, string $key, $default = null) |
||
167 | |||
168 | /** |
||
169 | * Get config value from config array if set (default otherwise) |
||
170 | * |
||
171 | * special version for aray values |
||
172 | * |
||
173 | * @param array $config |
||
174 | * @param string $key |
||
175 | * @param mixed $default |
||
176 | * |
||
177 | * @return mixed |
||
178 | * |
||
179 | * @see AbstractClient::getConfigDefault |
||
180 | */ |
||
181 | protected function getConfigDefaultArray(array $config, string $key, $default = null) |
||
189 | |||
190 | /** |
||
191 | * Get config value from config array if set (default otherwise) |
||
192 | * |
||
193 | * special version for files |
||
194 | * |
||
195 | * @param array $config |
||
196 | * @param string $key |
||
197 | * @param mixed $default |
||
198 | * |
||
199 | * @throws Exception in case file is specified but not readable |
||
200 | * |
||
201 | * @return mixed |
||
202 | * |
||
203 | * @see AbstractClient::getConfigDefault |
||
204 | */ |
||
205 | protected function getConfigDefaultReadableFile(array $config, string $key, $default = null) |
||
219 | |||
220 | protected function prepareConnectionOptions(array $config) |
||
227 | |||
228 | protected function prepareCredentials(array $config) |
||
233 | |||
234 | protected function prepareSSLOptions(array $config) |
||
244 | |||
245 | protected function prepareEPPServices(array $config) |
||
250 | |||
251 | protected function prepareEPPVersionLang(array $config) |
||
256 | |||
257 | protected function generateClientTransactionId() |
||
261 | |||
262 | /** |
||
263 | * Generate and send login frame |
||
264 | * |
||
265 | * @param bool|string $newPassword New password to set on login, false if not changing password |
||
266 | * |
||
267 | * @throws \Exception On unsuccessful login |
||
268 | * |
||
269 | * @return \AfriCC\EPP\Frame\Response Login response |
||
270 | */ |
||
271 | protected function login($newPassword = false) |
||
307 | } |
||
308 |