88use PagOnline \Exceptions \IgfsMissingParException ;
99use PagOnline \Exceptions \IOException ;
1010use PagOnline \Traits \HttpClient ;
11- use SimpleXMLElement ;
1211
13- /**
14- * Class BaseIgfsCg.
15- */
1612abstract class BaseIgfsCg implements IgfsCgInterface
1713{
1814 use HttpClient;
@@ -22,7 +18,7 @@ abstract class BaseIgfsCg implements IgfsCgInterface
2218 *
2319 * @var string
2420 */
25- const VERSION = '2.4.1.5 ' ;
21+ public const VERSION = '2.4.1.5 ' ;
2622
2723 /**
2824 * Signature Key.
@@ -36,18 +32,18 @@ abstract class BaseIgfsCg implements IgfsCgInterface
3632 *
3733 * @var null|string
3834 */
39- public $ serverURL = null ;
40- public $ serverURLs = null ;
35+ public $ serverURL ;
36+ public $ serverURLs ;
4137
42- public $ shopID = null ;
38+ public $ shopID ;
4339
44- public $ tid = null ;
45- public $ merID = null ;
46- public $ payInstr = null ;
40+ public $ tid ;
41+ public $ merID ;
42+ public $ payInstr ;
4743
48- public $ rc = null ;
49- public $ error = null ;
50- public $ errorDesc = null ;
44+ public $ rc ;
45+ public $ error ;
46+ public $ errorDesc ;
5147
5248 protected static $ soapBodyTag = 'Body ' ;
5349 protected static $ soapResponseParentTag = '' ;
@@ -62,18 +58,12 @@ abstract class BaseIgfsCg implements IgfsCgInterface
6258
6359 protected $ fields2Reset = false ;
6460
65- /**
66- * BaseIgfsCg constructor.
67- */
6861 public function __construct ()
6962 {
7063 $ this ->generateHttpClient ();
7164 }
7265
73- /**
74- * Reset fields.
75- */
76- public function resetFields ()
66+ public function resetFields (): void
7767 {
7868 $ this ->tid = null ;
7969 $ this ->merID = null ;
@@ -115,15 +105,15 @@ public function execute(): bool
115105 $ mapResponse = $ this ->executeHttp ($ this ->serverURL );
116106 } else {
117107 $ sURLs = $ this ->serverURLs ;
118- $ sURL = \ array_shift ($ sURLs );
108+ $ sURL = array_shift ($ sURLs );
119109 $ finished = false ;
120110 while (!$ finished ) {
121111 try {
122112 $ mapResponse = $ this ->executeHttp ($ sURL );
123113 $ finished = true ;
124114 } catch (ConnectionException $ e ) {
125115 if (!empty ($ sURLs )) {
126- $ sURL = \ array_shift ($ sURLs );
116+ $ sURL = array_shift ($ sURLs );
127117 } else {
128118 throw $ e ;
129119 }
@@ -206,12 +196,7 @@ abstract protected function getAdditionalRequestSignatureFields(): array;
206196
207197 /***
208198 * Generates a signature
209- *
210- * @param $signatureFields
211- *
212199 * @throws IgfsException
213- *
214- * @return string
215200 */
216201 protected function getSignature (array $ signatureFields ): string
217202 {
@@ -221,8 +206,8 @@ protected function getSignature(array $signatureFields): string
221206 $ data .= (string ) $ value ;
222207 }
223208
224- return \ base64_encode (\ hash_hmac ('sha256 ' , $ data , $ this ->kSig , true ));
225- } catch (\Exception $ e ) {
209+ return base64_encode (hash_hmac ('sha256 ' , $ data , $ this ->kSig , true ));
210+ } catch (\Throwable $ e ) {
226211 throw new IgfsException ($ e );
227212 }
228213 }
@@ -238,7 +223,7 @@ protected function getSignature(array $signatureFields): string
238223 */
239224 protected function setRequestSignature (&$ request ): void
240225 {
241- $ signatureFields = \ array_merge (
226+ $ signatureFields = array_merge (
242227 $ this ->getCommonRequestSignatureFields (),
243228 $ this ->getAdditionalRequestSignatureFields ()
244229 );
@@ -302,7 +287,7 @@ protected function replaceRequestParameter(
302287 $ xmlTag .= $ wrap_cdata ? "<![CDATA[ {$ value }]]> " : $ value ;
303288 $ xmlTag .= "</ {$ parameter }> " ;
304289 }
305- $ request = \ str_replace ('{ ' .$ parameter .'} ' , $ xmlTag , $ request );
290+ $ request = str_replace ('{ ' .$ parameter .'} ' , $ xmlTag , $ request );
306291 }
307292
308293 /**
@@ -327,12 +312,13 @@ abstract protected function getResponseSignature($response);
327312 /**
328313 * @param string $response
329314 *
330- * @return null|SimpleXMLElement
315+ * @return null|\ SimpleXMLElement
331316 */
332- protected function responseXmlToObject (string $ response ): ?SimpleXMLElement
317+ protected function responseXmlToObject (string $ response ): ?\ SimpleXMLElement
333318 {
334319 try {
335- $ dom = new SimpleXMLElement ($ response , LIBXML_NOERROR , false );
320+ $ dom = new \SimpleXMLElement ($ response , LIBXML_NOERROR , false );
321+
336322 /*$responseNode = $dom->children('soap', true)->{static::$soapBodyTag}
337323 ->children('ns1', true)->{static::$soapResponseParentTag}
338324 ->children()
@@ -399,8 +385,8 @@ protected function checkResponseSignature($response)
399385 /**
400386 * @param string $url
401387 *
402- * @throws \PagOnline\Exceptions\ IOException
403- * @throws \PagOnline\Exceptions\ IgfsException
388+ * @throws IOException
389+ * @throws IgfsException
404390 *
405391 * @return array
406392 */
0 commit comments