GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b32323...e0a7f1 )
by Florian
07:07
created

Util::setImapAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace Checkdomain\Comodo;
3
4
use Checkdomain\Comodo\Model\Exception\AccountException;
5
use Checkdomain\Comodo\Model\Exception\ArgumentException;
6
use Checkdomain\Comodo\Model\Exception\CSRException;
7
use Checkdomain\Comodo\Model\Exception\RequestException;
8
use Checkdomain\Comodo\Model\Exception\UnknownApiException;
9
use Checkdomain\Comodo\Model\Exception\UnknownException;
10
11
use Checkdomain\Comodo\Model\Result\AutoApplyResult;
12
use Checkdomain\Comodo\Model\Result\AutoReplaceResult;
13
use Checkdomain\Comodo\Model\Result\CollectSslResult;
14
use Checkdomain\Comodo\Model\Result\GetDCVEMailAddressListResult;
15
use Checkdomain\Comodo\Model\Result\GetMDCDomainDetailsResult;
16
use Checkdomain\Comodo\Model\Result\UpdateUserEvClickThroughResult;
17
18
/**
19
 * Class Util
20
 * Provides functions to communicate with the Comodo API,requires an Account object, given to the Communication-adapter
21
 */
22
class Util
23
{
24
    const COMODO_AUTO_APPLY_URL               = "https://secure.comodo.net/products/!AutoApplySSL";
25
    const COMODO_AUTO_REVOKE_URL              = "https://secure.comodo.net/products/!AutoRevokeSSL";
26
    const COMODO_DCV_MAIL_URL                 = "https://secure.comodo.net/products/!GetDCVEmailAddressList";
27
    const COMODO_DCV_RESEND_URL               = "https://secure.comodo.net/products/!ResendDCVEmail";
28
    const COMODO_AUTO_UPDATE_DCV_URL          = "https://secure.comodo.net/products/!AutoUpdateDCV";
29
    const COMODO_PROVIDE_EV_DETAILS_URL       = "https://secure.comodo.net/products/!ProvideEVDetails";
30
    const COMODO_MDC_DOMAIN_DETAILS_URL       = "https://secure.comodo.net/products/!GetMDCDomainDetails";
31
    const COMODO_AUTO_REPLACE_URL             = "https://secure.comodo.net/products/!AutoReplaceSSL";
32
    const COMODO_COLLECT_SSL_URL              = "https://secure.comodo.net/products/download/CollectSSL";
33
    const COMODO_UPDATE_USER_EV_CLICK_THROUGH = "https://secure.comodo.net/products/!UpdateUserEvClickThrough";
34
35
    const COMODO_DCV_CODE_URL = "https://secure.comodo.net/products/EnterDCVCode2";
36
37
    /**
38
     * @var CommunicationAdapter
39
     */
40
    protected $communicationAdapter;
41
42
    /**
43
     * @var ImapAdapter
44
     */
45
    protected $imapAdapter;
46
47
    /**
48
     * @var ImapHelper
49
     */
50
    protected $imapHelper;
51
52
    /**
53
     * Constructs the Util with a communicationAdapter
54
     *
55
     * @param CommunicationAdapter|null $communicationAdapter
56
     * @param ImapAdapter|null       $imapAdapter
57
     * @param ImapHelper|null           $imapHelper
58
     */
59
    public function __construct(CommunicationAdapter $communicationAdapter, ImapAdapter $imapAdapter, ImapHelper $imapHelper)
60
    {
61
        $this->communicationAdapter = $communicationAdapter;
62
        $this->imapAdapter       = $imapAdapter;
63
        $this->imapHelper           = $imapHelper;
64
    }
65
66
67
    /**
68
     * @return CommunicationAdapter
69
     */
70
    public function getCommunicationAdapter()
71
    {
72
        return $this->communicationAdapter;
73
    }
74
75
    /**
76
     * @param CommunicationAdapter $communicationAdapter
77
     *
78
     * @return Util
79
     */
80
    public function setCommunicationAdapter(CommunicationAdapter $communicationAdapter)
81
    {
82
        $this->communicationAdapter = $communicationAdapter;
83
84
        return $this;
85
    }
86
87
    /**
88
     * @return ImapHelper
89
     */
90
    public function getImapHelper()
91
    {
92
        return $this->imapHelper;
93
    }
94
95
    /**
96
     * @param ImapHelper $imapHelper
97
     *
98
     * @return Util
99
     */
100
    public function setImapHelper(ImapHelper $imapHelper)
101
    {
102
        $this->imapHelper = $imapHelper;
103
104
        return $this;
105
    }
106
107
    /**
108
     * @return ImapAdapter
109
     */
110
    public function getImapAdapter()
111
    {
112
        return $this->imapAdapter;
113
    }
114
115
    /**
116
     * @param ImapAdapter $imapAdapter
117
     *
118
     * @return Util
119
     */
120
    public function setImapAdapter(ImapAdapter $imapAdapter)
121
    {
122
        $this->imapAdapter = $imapAdapter;
123
124
        return $this;
125
    }
126
127
    /**
128
     * Function apply for a certificate
129
     *
130
     * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/
131
     *
132
     * @param array $params
133
     *
134
     * @return AutoApplyResult
135
     * @throws Model\Exception\AccountException
136
     * @throws Model\Exception\ArgumentException
137
     * @throws Model\Exception\CSRException
138
     * @throws Model\Exception\RequestException
139
     * @throws Model\Exception\UnknownApiException
140
     * @throws Model\Exception\UnknownException
141
     */
142
    public function autoApplySSL(array $params)
143
    {
144
        // Two choices, we want url-encoded
145
        $params["responseFormat"] = CommunicationAdapter::RESPONSE_URL_ENCODED;
146
147
        // Send request
148
        $arr = $this
149
            ->communicationAdapter
150
            ->sendToApi(self::COMODO_AUTO_APPLY_URL, $params, CommunicationAdapter::RESPONSE_URL_ENCODED);
151
152
        // Successful
153
        if ($arr["errorCode"] == 1 || $arr["errorCode"] == 0) {
154
            $result = new AutoApplyResult();
155
156
            if ($arr["errorCode"] == 0) {
157
                $paid = true;
158
            } else {
159
                $paid = false;
160
            }
161
162
            $result
163
                ->setPaid($paid)
164
                ->setCertificateID($arr["certificateID"])
165
                ->setExpectedDeliveryTime($arr["expectedDeliveryTime"])
166
                ->setOrderNumber($arr["orderNumber"])
167
                ->setTotalCost($arr["totalCost"])
168
                ->setRequestQuery($arr['requestQuery']);
169
170
            return $result;
171
        } else {
172
            throw $this->createException($arr);
173
        }
174
    }
175
176
    /**
177
     * @param array $params
178
     *
179
     * @return UpdateUserEvClickThroughResult
180
     * @throws AccountException
181
     * @throws ArgumentException
182
     * @throws CSRException
183
     * @throws RequestException
184
     * @throws UnknownApiException
185
     * @throws UnknownException
186
     */
187
    public function updateUserEvClickThrough(array $params)
188
    {
189
        // Send request
190
        $arr = $this
191
            ->communicationAdapter
192
            ->sendToApi(
193
                self::COMODO_UPDATE_USER_EV_CLICK_THROUGH,
194
                $params,
195
                CommunicationAdapter::RESPONSE_URL_ENCODED
196
            );
197
198
        // Successful
199
        if ($arr["errorCode"] == 0) {
200
            $result = new UpdateUserEvClickThroughResult();
201
202
            $result
203
                ->setStatus($arr['status']);
204
205
            return $result;
206
        } else {
207
            throw $this->createException($arr);
208
        }
209
    }
210
211
    /**
212
     * Function update for a certificate
213
     *
214
     * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/
215
     *
216
     * @param array $params
217
     *
218
     * @return AutoApplyResult
219
     * @throws Model\Exception\AccountException
220
     * @throws Model\Exception\ArgumentException
221
     * @throws Model\Exception\CSRException
222
     * @throws Model\Exception\RequestException
223
     * @throws Model\Exception\UnknownApiException
224
     * @throws Model\Exception\UnknownException
225
     */
226 View Code Duplication
    public function autoReplaceSSL(array $params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
227
    {
228
        // Two choices, we want url-encoded
229
        $params["responseFormat"] = CommunicationAdapter::RESPONSE_URL_ENCODED;
230
231
        // Send request
232
        $arr = $this
233
            ->communicationAdapter
234
            ->sendToApi(
235
                self::COMODO_AUTO_REPLACE_URL,
236
                $params,CommunicationAdapter::RESPONSE_URL_ENCODED
237
            );
238
239
        // Successful
240
        if ($arr["errorCode"] == 0) {
241
            $result = new AutoReplaceResult();
242
243
            $result
244
                ->setCertificateID($arr["certificateID"])
245
                ->setExpectedDeliveryTime($arr["expectedDeliveryTime"]);
246
247
            return $result;
248
        } else {
249
            throw $this->createException($arr);
250
        }
251
    }
252
253
    /**
254
     * Function to revoke order
255
     *
256
     * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/
257
     *
258
     * @param array $params
259
     *
260
     * @return bool
261
     * @throws Model\Exception\AccountException
262
     * @throws Model\Exception\ArgumentException
263
     * @throws Model\Exception\RequestException
264
     * @throws Model\Exception\UnknownApiException
265
     * @throws Model\Exception\UnknownException
266
     */
267
    public function autoRevokeSSL(array $params)
268
    {
269
        // Two choices, we want url-encoded
270
        $params["responseFormat"] = CommunicationAdapter::RESPONSE_URL_ENCODED;
271
272
        return $this->sendBooleanRequest(
273
            self::COMODO_AUTO_REVOKE_URL,
274
            $params,
275
            CommunicationAdapter::RESPONSE_URL_ENCODED
276
        );
277
    }
278
279
    /**
280
     * Function to auto update dcv
281
     *
282
     * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/
283
     *
284
     * @param array $params
285
     *
286
     * @return bool
287
     * @throws Model\Exception\AccountException
288
     * @throws Model\Exception\ArgumentException
289
     * @throws Model\Exception\RequestException
290
     * @throws Model\Exception\UnknownApiException
291
     * @throws Model\Exception\UnknownException
292
     */
293
    public function autoUpdateDCV(array $params)
294
    {
295
        return $this->sendBooleanRequest(
296
            self::COMODO_AUTO_UPDATE_DCV_URL,
297
            $params,
298
            CommunicationAdapter::RESPONSE_URL_ENCODED
299
        );
300
    }
301
302
    /**
303
     * Function to get details of a certificate
304
     *
305
     * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/
306
     *
307
     * @param array $params
308
     *
309
     * @return CollectSslResult
310
     * @throws Model\Exception\AccountException
311
     * @throws Model\Exception\ArgumentException
312
     * @throws Model\Exception\CSRException
313
     * @throws Model\Exception\RequestException
314
     * @throws Model\Exception\UnknownApiException
315
     * @throws Model\Exception\UnknownException
316
     */
317
    public function collectSsl(array $params)
318
    {
319
        // Not decode the following indexes
320
        $notDecode = array('caCertificate', 'certificate', 'netscapeCertificateSequence', 'zipFile');
321
322
        // Force threating as array
323
        $forceArray = array('caCertificate');
324
325
        // Two choices, we want url-encoded
326
        $params["responseFormat"] = CommunicationAdapter::RESPONSE_URL_ENCODED;
327
328
        // Send request
329
        $arr = $this
330
            ->communicationAdapter
331
            ->sendToApi(
332
                self::COMODO_COLLECT_SSL_URL,
333
                $params,
334
                CommunicationAdapter::RESPONSE_URL_ENCODED,
335
                $notDecode,
336
                $forceArray
337
            );
338
339
        // Successful
340
        if ($arr["errorCode"] >= 0) {
341
            $result = new CollectSslResult();
342
343
            $this->fill($result, $arr, array('notBefore', 'notAfter'));
344
345
            return $result;
346
        } else {
347
            throw $this->createException($arr);
348
        }
349
    }
350
351
    /**
352
     * @param CollectSslResult $object
353
     * @param array            $arr
354
     * @param array            $timestampFields
355
     *
356
     * @return $this
357
     */
358
    protected function fill(CollectSslResult $object, array $arr, array $timestampFields = array())
359
    {
360
        foreach ($arr as $key => $value) {
361
            if (in_array($key, $timestampFields)) {
362
                $value = new \DateTime('@' . $value);
363
            }
364
365
            $function = 'set' . ucfirst($key);
366
367
            // For example setErrorCode does not exists, so check before
368
            if(method_exists($object, $function)) {
369
                call_user_func(array($object, $function), $value);
370
            }
371
        }
372
373
        return $this;
374
    }
375
376
    /**
377
     * Function to resend the DCV Email
378
     *
379
     * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/
380
     *
381
     * @param array $params
382
     *
383
     * @return bool
384
     * @throws Model\Exception\AccountException
385
     * @throws Model\Exception\ArgumentException
386
     * @throws Model\Exception\RequestException
387
     * @throws Model\Exception\UnknownApiException
388
     * @throws Model\Exception\UnknownException
389
     */
390
    public function resendDCVEMail(array $params)
391
    {
392
        return $this
393
            ->sendBooleanRequest(
394
                self::COMODO_DCV_RESEND_URL,
395
                $params,
396
                CommunicationAdapter::RESPONSE_URL_ENCODED
397
            );
398
    }
399
400
    /**
401
     * @param array $params
402
     *
403
     * @deprecated Comodo support told this function doesn't have any effect anymore
404
     *
405
     * @return bool
406
     * @throws Model\Exception\AccountException
407
     * @throws Model\Exception\ArgumentException
408
     * @throws Model\Exception\CSRException
409
     * @throws Model\Exception\RequestException
410
     * @throws Model\Exception\UnknownApiException
411
     * @throws Model\Exception\UnknownException
412
     */
413
    public function provideEVDetails(array $params)
414
    {
415
        return $this->sendBooleanRequest(
416
            self::COMODO_PROVIDE_EV_DETAILS_URL,
417
            $params,
418
            CommunicationAdapter::RESPONSE_URL_ENCODED
419
        );
420
    }
421
422
    /**
423
     * Function to get the DCV e-mail address-list
424
     *
425
     * See documentation of params at https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/
426
     *
427
     * @param array $params
428
     *
429
     * @return GetDCVEMailAddressListResult
430
     *
431
     * @throws Model\Exception\AccountException
432
     * @throws Model\Exception\ArgumentException
433
     * @throws Model\Exception\RequestException
434
     * @throws Model\Exception\UnknownApiException
435
     * @throws Model\Exception\UnknownException
436
     */
437
    public function getDCVEMailAddressList(array $params)
438
    {
439
        // Force threating as array
440
        $forceArray = array('whois_email', 'level2_email', 'level3_email');
441
442
        // Response is always new line encoded
443
        $responseArray = $this
444
            ->communicationAdapter
445
            ->sendToApi(
446
                self::COMODO_DCV_MAIL_URL,
447
                $params,
448
                CommunicationAdapter::RESPONSE_NEW_LINE,
449
                null,
450
                $forceArray
451
            );
452
453
        if ($responseArray["errorCode"] == 0) {
454
            $result = new GetDCVEMailAddressListResult();
455
456
            $result
457
                ->setDomainName($responseArray["domain_name"])
458
                ->setWhoisEmail($responseArray["whois_email"])
459
                ->setLevel2Emails($responseArray["level2_email"])
460
                ->setRequestQuery($responseArray['requestQuery']);
461
462
            if (isset($responseArray["level3_email"])) {
463
                $result->setLevel3Emails($responseArray["level3_email"]);
464
            }
465
466
            return $result;
467
        } else {
468
            throw $this->createException($responseArray);
469
        }
470
    }
471
472
    /**
473
     * Function to get details of a order-number (this API support just one domain)
474
     *
475
     * https://secure.comodo.net/api/pdf/webhostreseller/sslcertificates/GetMDCDomainDetails%20v1.00.pdf
476
     *
477
     * @param array $params
478
     *
479
     * @return GetMDCDomainDetailsResult
480
     *
481
     * @throws Model\Exception\AccountException
482
     * @throws Model\Exception\ArgumentException
483
     * @throws Model\Exception\CSRException
484
     * @throws Model\Exception\RequestException
485
     * @throws Model\Exception\UnknownApiException
486
     * @throws Model\Exception\UnknownException
487
     */
488 View Code Duplication
    public function getMDCDomainDetails(array $params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
489
    {
490
        // Response is always new line encoded
491
        $responseArray = $this
492
            ->communicationAdapter
493
            ->sendToApi(
494
                self::COMODO_MDC_DOMAIN_DETAILS_URL,
495
                $params,
496
                CommunicationAdapter::RESPONSE_URL_ENCODED
497
            );
498
499
        if ($responseArray["errorCode"] == 0) {
500
            $result = new GetMDCDomainDetailsResult();
501
502
            $result
503
                ->setDomainName($responseArray["1_domainName"])
504
                ->setDcvMethod($responseArray["1_dcvMethod"])
505
                ->setDcvStatus($responseArray["1_dcvStatus"]);
506
507
            return $result;
508
        } else {
509
            throw $this->createException($responseArray);
510
        }
511
    }
512
513
    /**
514
     * Function to enter the DCV code, coming from DCV E-Mail
515
     *
516
     * @param array $params
517
     *
518
     * @return bool
519
     * @throws Model\Exception\UnknownException
520
     * @throws Model\Exception\ArgumentException
521
     */
522
    public function enterDCVCode(array $params)
523
    {
524
        // Check parameters
525
        if (!isset($params["dcvCode"])) {
526
            throw new ArgumentException(-3, 'Please provide an order-number', 'dcvCode', '');
527
        }
528
529
        if (!isset($params["orderNumber"])) {
530
            throw new ArgumentException(-3, 'Please provide an order-number', 'orderNumber', '');
531
        }
532
533
        // this is not a official request, so we need to use the website
534
        $responseString = $this
535
            ->communicationAdapter
536
            ->sendToWebsite(self::COMODO_DCV_CODE_URL, $params);
537
538
        // Decode answer from website
539
        if (stristr($responseString, "You have entered the correct Domain Control Validation code") !== false) {
540
            return true;
541
        } else if (stristr($responseString, 'the certificate has already been issued') !== false) {
542
            throw new ArgumentException(-104, 'The certificate has already been issued', 'certificate', $responseString);
543
        } else if (stristr($responseString, 'Invalid Validation Code!') !== false) {
544
            throw new ArgumentException(-103, 'Invalid Validation Code', 'validation-code', $responseString);
545
        } else {
546
            throw new UnknownException(99, 'UnknownException', $responseString);
547
        }
548
    }
549
550
    /**
551
     * @param string $url
552
     * @param array  $params
553
     * @param int    $type
554
     *
555
     * @return bool
556
     * @throws AccountException
557
     * @throws ArgumentException
558
     * @throws CSRException
559
     * @throws RequestException
560
     * @throws UnknownApiException
561
     * @throws UnknownException
562
     */
563
    protected function sendBooleanRequest($url, array $params, $type)
564
    {
565
        // Response is always url encoded
566
        $responseArray = $this
567
            ->communicationAdapter
568
            ->sendToApi(
569
                $url,
570
                $params,
571
                $type
572
            );
573
574
        if ($responseArray["errorCode"] == 0) {
575
            return true;
576
        } else {
577
            throw $this->createException($responseArray);
578
        }
579
    }
580
581
    /**
582
     * @param string   $domainName
583
     * @param null     $orderNumbers
584
     * @param \Closure $callbackFunction
585
     *
586
     * @return array
587
     */
588
    public function getMails($domainName, $orderNumbers = null, \Closure $callbackFunction = null)
589
    {
590
        $orList    = ' OR ';
591
        $whereList = ' BODY "' . $domainName . '"';
592
        $whereList .= ' SUBJECT "' . $domainName . '"';
593
594
        if (is_array($orderNumbers)) {
595
            foreach ($orderNumbers as $orderNumber) {
596
                $orList .= ' OR OR ';
597
                $whereList .= ' BODY "' . $orderNumber . '"';
598
                $whereList .= ' SUBJECT "' . $orderNumber . '"';
599
            }
600
        }
601
602
        $search = $orList . " " . $whereList;
603
604
        return $this->imapHelper
605
            ->fetchMails($this->imapAdapter, array(), $search, null, false, false, $callbackFunction);
606
    }
607
608
    /**
609
     * @param bool     $markProcessed
610
     * @param \Closure $callbackFunction
611
     *
612
     * @return array
613
     */
614
    public function getUnprocessedMails($markProcessed = true, \Closure $callbackFunction = null)
615
    {
616
        $search = ' NOT KEYWORD "' . ImapHelper::PROCESSED_FLAG . '"';
617
618
        return $this
619
            ->imapHelper
620
            ->fetchMails(
621
                $this->imapAdapter,
622
                array(),
623
                $search,
624
                null,
625
                $markProcessed,
626
                true,
627
                $callbackFunction
628
            );
629
    }
630
631
    /**
632
     * Function to create an exception for API errorcodes
633
     *
634
     * @param array $responseArray
635
     *
636
     * @return AccountException|ArgumentException|CSRException|RequestException|UnknownApiException|UnknownException
637
     *
638
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
639
     */
640
    protected function createException(array $responseArray)
641
    {
642
        switch ($responseArray["errorCode"]) {
643
            case -1: // Not using https:
644
            case -17: // Wrong HTTP-method
645
                return new RequestException(
646
                    $responseArray["errorCode"],
647
                    $responseArray["errorMessage"],
648
                    $responseArray["responseString"]
649
                );
650
651
            case -2: // unrecognized argument
652
            case -3: // missing argument
653
            case -4: // invalid argument
654
            case -7: // invalid ISO Country
655
            case -18: // Name = Fully-Qualified Domain Name
656
            case -35: // Name = = IP
657
            case -19: // Name = = Accessible IP
658
                return new ArgumentException(
659
                    $responseArray["errorCode"],
660
                    $responseArray["errorMessage"],
661
                    ((isset($responseArray["errorItem"])) ? $responseArray["errorItem"] : null),
662
                    $responseArray["responseString"]
663
                );
664
665
            case -16: // Permission denied
666
            case -15: // insufficient credits
667
                return new AccountException(
668
                    $responseArray["errorCode"],
669
                    $responseArray["errorMessage"],
670
                    $responseArray["responseString"]
671
                );
672
673
            case -5: // contains wildcard
674
            case -6: // no wildcard, but must have
675
            case -8: // missing field
676
            case -9: // base64 decode exception
677
            case -10: // decode exception
678
            case -11: // unsupported algorithm
679
            case -12: // invalid signature
680
            case -13: // unsupported key size
681
            case -20: // Already rejected / Order relevated
682
            case -21: // Already revoked
683
            case -26: // current being issued
684
            case -40: // key compromised
685
                return new CSRException(
686
                    $responseArray["errorCode"],
687
                    $responseArray["errorMessage"],
688
                    $responseArray["responseString"]
689
                );
690
691
            case -14:
692
                return new UnknownApiException(
693
                    $responseArray["errorCode"],
694
                    $responseArray["errorMessage"],
695
                    $responseArray["responseString"]
696
                );
697
698
            default:
699
                return new UnknownException(
700
                    $responseArray["errorCode"],
701
                    $responseArray["errorMessage"],
702
                    $responseArray["responseString"]
703
                );
704
        }
705
    }
706
}
707