Completed
Push — 1.9 ( 30c3e5...ca8b96 )
by
unknown
42:25
created

SoapTransport::lookUpForServerTime()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 0
1
<?php
2
3
namespace OroCRM\Bundle\MagentoBundle\Provider\Transport;
4
5
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
6
7
use Oro\Bundle\IntegrationBundle\Entity\Transport;
8
use Oro\Bundle\IntegrationBundle\Provider\SOAPTransport as BaseSOAPTransport;
9
use Oro\Bundle\IntegrationBundle\Utils\ConverterUtils;
10
use Oro\Bundle\SecurityBundle\Encoder\Mcrypt;
11
12
use OroCRM\Bundle\MagentoBundle\Entity\MagentoSoapTransport;
13
use OroCRM\Bundle\MagentoBundle\Exception\ExtensionRequiredException;
14
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\CartsBridgeIterator;
15
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\CustomerBridgeIterator;
16
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\CustomerGroupSoapIterator;
17
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\CustomerSoapIterator;
18
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\NewsletterSubscriberBridgeIterator;
19
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\OrderBridgeIterator;
20
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\OrderSoapIterator;
21
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\RegionSoapIterator;
22
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\StoresSoapIterator;
23
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\WebsiteSoapIterator;
24
use OroCRM\Bundle\MagentoBundle\Service\WsdlManager;
25
use OroCRM\Bundle\MagentoBundle\Utils\WSIUtils;
26
27
/**
28
 * Magento SOAP transport
29
 * used to fetch and pull data to/from Magento instance
30
 * with sessionId param using SOAP requests
31
 *
32
 * @package OroCRM\Bundle\MagentoBundle
33
 * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
34
 */
35
class SoapTransport extends BaseSOAPTransport implements MagentoTransportInterface, ServerTimeAwareInterface
36
{
37
    const REQUIRED_EXTENSION_VERSION = '1.2.0';
38
39
    const ACTION_CUSTOMER_LIST = 'customerCustomerList';
40
    const ACTION_CUSTOMER_INFO = 'customerCustomerInfo';
41
    const ACTION_CUSTOMER_UPDATE = 'customerCustomerUpdate';
42
    const ACTION_CUSTOMER_DELETE = 'customerCustomerDelete';
43
    const ACTION_CUSTOMER_CREATE = 'customerCustomerCreate';
44
    const ACTION_CUSTOMER_ADDRESS_LIST = 'customerAddressList';
45
    const ACTION_CUSTOMER_ADDRESS_INFO = 'customerAddressInfo';
46
    const ACTION_CUSTOMER_ADDRESS_UPDATE = 'customerAddressUpdate';
47
    const ACTION_CUSTOMER_ADDRESS_DELETE = 'customerAddressDelete';
48
    const ACTION_CUSTOMER_ADDRESS_CREATE = 'customerAddressCreate';
49
    const ACTION_ADDRESS_LIST = 'customerAddressList';
50
    const ACTION_GROUP_LIST = 'customerGroupList';
51
    const ACTION_STORE_LIST = 'storeList';
52
    const ACTION_ORDER_LIST = 'salesOrderList';
53
    const ACTION_ORDER_INFO = 'salesOrderInfo';
54
    const ACTION_CART_INFO = 'shoppingCartInfo';
55
    const ACTION_COUNTRY_LIST = 'directoryCountryList';
56
    const ACTION_REGION_LIST = 'directoryRegionList';
57
    const ACTION_PING = 'oroPing';
58
59
    const ACTION_ORO_CART_LIST = 'oroQuoteList';
60
    const ACTION_ORO_ORDER_LIST = 'oroOrderList';
61
    const ACTION_ORO_ORDER_INFO = 'oroOrderInfo';
62
    const ACTION_ORO_CUSTOMER_LIST = 'oroCustomerList';
63
    const ACTION_ORO_CUSTOMER_INFO = 'oroCustomerInfo';
64
    const ACTION_ORO_CUSTOMER_ADDRESS_LIST = 'oroCustomerAddressList';
65
    const ACTION_ORO_CUSTOMER_ADDRESS_INFO = 'oroCustomerAddressInfo';
66
    const ACTION_ORO_CUSTOMER_CREATE = 'oroCustomerCreate';
67
    const ACTION_ORO_CUSTOMER_UPDATE = 'oroCustomerUpdate';
68
    const ACTION_ORO_NEWSLETTER_SUBSCRIBER_LIST = 'newsletterSubscriberList';
69
    const ACTION_ORO_NEWSLETTER_SUBSCRIBER_CREATE = 'newsletterSubscriberCreate';
70
    const ACTION_ORO_NEWSLETTER_SUBSCRIBER_UPDATE = 'newsletterSubscriberUpdate';
71
    const ACTION_ORO_WEBSITE_LIST = 'oroWebsiteList';
72
73
    const SOAP_FAULT_ADDRESS_DOES_NOT_EXIST = 102;
74
75
    /** @var string */
76
    protected $sessionId;
77
78
    /** @var Mcrypt */
79
    protected $encoder;
80
81
    /** @var bool */
82
    protected $isExtensionInstalled;
83
84
    /** @var string */
85
    protected $magentoVersion;
86
87
    /** @var string */
88
    protected $extensionVersion;
89
90
    /** @var bool */
91
    protected $isWsiMode = false;
92
93
    /** @var string */
94
    protected $adminUrl;
95
96
    /** @var  string */
97
    protected $serverTime;
98
99
    /** @var array */
100
    protected $dependencies = [];
101
102
    /** @var WsdlManager */
103
    protected $wsdlManager;
104
105
    /** @var array */
106
    protected $auth = [];
107
108
    /**
109
     * @var array
110
     */
111
    protected $bundleConfig;
112
113
    /**
114
     * @param Mcrypt $encoder
115
     * @param WsdlManager $wsdlManager
116
     * @param array $bundleConfig
117
     */
118
    public function __construct(Mcrypt $encoder, WsdlManager $wsdlManager, array $bundleConfig = [])
119
    {
120
        $this->encoder = $encoder;
121
        $this->wsdlManager = $wsdlManager;
122
        $this->bundleConfig = $bundleConfig;
123
    }
124
125
    /**
126
     * {@inheritdoc}
127
     */
128
    public function init(Transport $transportEntity)
129
    {
130
        /**
131
         * Cache WSDL and force transport entity to use it instead of original URL.
132
         * This should be done before parent::init as settings will be cached there.
133
         */
134
        if ($transportEntity instanceof MagentoSoapTransport) {
135
            $wsdlUrl = $transportEntity->getWsdlUrl();
136
137
            // Save auth information to be able to perform requests.
138
            $urlParts = parse_url($wsdlUrl);
139
            if (isset($urlParts['user'], $urlParts['pass'])) {
140
                $this->auth['login'] = $urlParts['user'];
141
                $this->auth['password'] = $urlParts['pass'];
142
            }
143
144
            // Load WSDL to local cache.
145
            if (!$this->wsdlManager->isCacheLoaded($wsdlUrl)) {
146
                $this->wsdlManager->loadWsdl($wsdlUrl);
147
            }
148
149
            // Set cached WSDL path to transport entity.
150
            $transportEntity->setWsdlCachePath($this->wsdlManager->getCachedWsdlPath($wsdlUrl));
151
        }
152
153
        parent::init($transportEntity);
154
155
        $wsiMode = $this->settings->get('wsi_mode', false);
156
        $apiUser = $this->settings->get('api_user', false);
157
        $apiKey = $this->settings->get('api_key', false);
158
        $apiKey = $this->encoder->decryptData($apiKey);
159
160
        if (!$apiUser || !$apiKey) {
161
            throw new InvalidConfigurationException(
162
                "Magento SOAP transport require 'api_key' and 'api_user' settings to be defined."
163
            );
164
        }
165
166
        // revert initial state
167
        $this->isExtensionInstalled = null;
168
        $this->adminUrl = null;
169
        $this->isWsiMode = $wsiMode;
170
171
        /** @var string sessionId returned by Magento API login method */
172
        $this->sessionId = null;
173
        $this->sessionId = $this->call('login', ['username' => $apiUser, 'apiKey' => $apiKey]);
174
175
        $this->checkExtensionFunctions();
176
    }
177
178
    protected function checkExtensionFunctions()
179
    {
180
        $functions = (array)$this->client->__getFunctions();
181
182
        $isExtensionInstalled = (bool)array_filter(
183
            $functions,
184
            function ($definition) {
185
                return false !== strpos($definition, self::ACTION_PING);
186
            }
187
        );
188
189
        if (!$isExtensionInstalled) {
190
            $this->isExtensionInstalled = false;
191
            $this->adminUrl = false;
0 ignored issues
show
Documentation Bug introduced by
The property $adminUrl was declared of type string, but false is of type false. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
192
        }
193
    }
194
195
    /**
196
     * Disable wsdl caching by PHP.
197
     *
198
     * {@inheritdoc}
199
     */
200
    protected function getSoapClient($wsdlUrl, array $options = [])
201
    {
202
        $options['cache_wsdl'] = WSDL_CACHE_NONE;
203
        if (!isset($options['login'], $options['password'])) {
204
            $options = array_merge($options, $this->auth);
205
        }
206
        if (!empty($this->bundleConfig['sync_settings']['skip_ssl_verification'])) {
207
            $context = stream_context_create(
208
                [
209
                    'ssl' => [
210
                        'verify_peer' => false,
211
                        'verify_peer_name' => false,
212
                        'allow_self_signed' => true
213
                    ]
214
                ]
215
            );
216
217
            $options['stream_context'] = $context;
218
        }
219
220
        return parent::getSoapClient($wsdlUrl, $options);
221
    }
222
223
    /**
224
     * {@inheritdoc}
225
     */
226
    public function call($action, $params = [])
227
    {
228
        if (null !== $this->sessionId) {
229
            $params = array_merge(['sessionId' => $this->sessionId], (array)$params);
230
        }
231
232
        if ($this->logger) {
233
            $this->logger->debug(
234
                sprintf(
235
                    '[%.1fMB/%.1fMB] Call %s action with %s parameters',
236
                    memory_get_usage() / 1024 / 1024,
237
                    memory_get_peak_usage() / 1024 / 1024,
238
                    $action,
239
                    json_encode($params)
240
                )
241
            );
242
        }
243
244
        if ($this->isWsiMode) {
245
            $result = parent::call($action, [(object)$params]);
246
            $result = WSIUtils::parseWSIResponse($result);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as \OroCRM\Bundle\MagentoBu...rseWSIResponse($result) (which targets OroCRM\Bundle\MagentoBun...ils::parseWSIResponse()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
247
        } else {
248
            $result = parent::call($action, $params);
249
        }
250
251
        $this->lookUpForServerTime();
252
253
        return $result;
254
    }
255
256
    /**
257
     * {@inheritdoc}
258
     */
259
    public function isExtensionInstalled()
260
    {
261
        if (null === $this->isExtensionInstalled) {
262
            $this->pingMagento();
263
        }
264
265
        return $this->isExtensionInstalled;
266
    }
267
268
    /**
269
     * {@inheritdoc}
270
     */
271
    public function getMagentoVersion()
272
    {
273
        if (null === $this->isExtensionInstalled) {
274
            $this->pingMagento();
275
        }
276
277
        return $this->magentoVersion;
278
    }
279
280
    /**
281
     * {@inheritdoc}
282
     */
283
    public function getExtensionVersion()
284
    {
285
        if (null === $this->isExtensionInstalled) {
286
            $this->pingMagento();
287
        }
288
289
        return $this->extensionVersion;
290
    }
291
292
    /**
293
     * {@inheritdoc}
294
     */
295
    public function isSupportedExtensionVersion()
296
    {
297
        return $this->isExtensionInstalled()
298
            && version_compare($this->getExtensionVersion(), self::REQUIRED_EXTENSION_VERSION, 'ge');
299
    }
300
301
    /**
302
     * Pings magento and fill data related to Bridge Extension.
303
     *
304
     * @return $this
305
     */
306
    protected function pingMagento()
307
    {
308
        if (null === $this->isExtensionInstalled && null === $this->adminUrl) {
309
            try {
310
                $result = $this->call(self::ACTION_PING);
311
                $this->isExtensionInstalled = !empty($result->version);
312
                if ($this->isExtensionInstalled) {
313
                    $this->extensionVersion = $result->version;
314
                }
315
                if (!empty($result->mage_version)) {
316
                    $this->magentoVersion = $result->mage_version;
317
                }
318
                if (!empty($result->admin_url)) {
319
                    $this->adminUrl = $result->admin_url;
320
                } else {
321
                    $this->adminUrl = false;
0 ignored issues
show
Documentation Bug introduced by
The property $adminUrl was declared of type string, but false is of type false. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
322
                }
323
            } catch (\Exception $e) {
324
                $this->isExtensionInstalled
325
                    = $this->adminUrl
326
                    = false;
327
            }
328
        }
329
330
        return $this;
331
    }
332
333
    /**
334
     * {@inheritdoc}
335
     */
336
    public function getAdminUrl()
337
    {
338
        if (null === $this->adminUrl) {
339
            $this->pingMagento();
340
        }
341
342
        return $this->adminUrl;
343
    }
344
345
    /**
346
     * {@inheritdoc}
347
     */
348
    public function getServerTime()
349
    {
350
        return $this->serverTime;
351
    }
352
353
    /**
354
     * {@inheritdoc}
355
     */
356
    public function getOrders()
357
    {
358
        $settings = $this->settings->all();
359
360
        if ($this->isExtensionInstalled()) {
361
            return new OrderBridgeIterator($this, $settings);
362
        } else {
363
            return new OrderSoapIterator($this, $settings);
364
        }
365
    }
366
367
    /**
368
     * {@inheritdoc}
369
     */
370
    public function getOrderInfo($incrementId)
371
    {
372
        if ($this->isSupportedExtensionVersion()) {
373
            $endpoint = self::ACTION_ORO_ORDER_INFO;
374
        } else {
375
            $endpoint = self::ACTION_ORDER_INFO;
376
        }
377
378
        return $this->call($endpoint, ['orderIncrementId' => $incrementId]);
379
    }
380
381
    /**
382
     * {@inheritdoc}
383
     */
384
    public function getCarts()
385
    {
386
        if ($this->isExtensionInstalled()) {
387
            return new CartsBridgeIterator($this, $this->settings->all());
388
        }
389
390
        throw new ExtensionRequiredException();
391
    }
392
393
    /**
394
     * {@inheritdoc}
395
     */
396
    public function getCustomers()
397
    {
398
        $settings = $this->settings->all();
399
400
        if ($this->isExtensionInstalled()) {
401
            return new CustomerBridgeIterator($this, $settings);
402
        } else {
403
            return new CustomerSoapIterator($this, $settings);
404
        }
405
    }
406
407
    /**
408
     * {@inheritdoc}
409
     */
410
    public function getCustomerGroups()
411
    {
412
        return new CustomerGroupSoapIterator($this);
413
    }
414
415
    /**
416
     * {@inheritdoc}
417
     */
418
    public function getStores()
419
    {
420
        return new StoresSoapIterator($this);
421
    }
422
423
    /**
424
     * {@inheritdoc}
425
     */
426
    public function getWebsites()
427
    {
428
        return new WebsiteSoapIterator($this);
429
    }
430
431
    /**
432
     * {@inheritdoc}
433
     */
434
    public function getRegions()
435
    {
436
        return new RegionSoapIterator($this, $this->settings->all());
437
    }
438
439
    /**
440
     * {@inheritdoc}
441
     */
442
    public function getCustomerAddresses($originId)
443
    {
444
        if ($this->isSupportedExtensionVersion()) {
445
            $endpoint = SoapTransport::ACTION_ORO_CUSTOMER_ADDRESS_LIST;
446
        } else {
447
            $endpoint = SoapTransport::ACTION_CUSTOMER_ADDRESS_LIST;
448
        }
449
450
        $addresses = $this->call($endpoint, ['customerId' => $originId]);
451
        $addresses = WSIUtils::processCollectionResponse($addresses);
452
453
        return ConverterUtils::objectToArray($addresses);
0 ignored issues
show
Documentation introduced by
$addresses is of type array, but the function expects a object<stdClass>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
454
    }
455
456
    /**
457
     * {@inheritdoc}
458
     */
459
    public function createCustomer(array $customerData)
460
    {
461
        if ($this->isSupportedExtensionVersion()) {
462
            $createEndpoint = SoapTransport::ACTION_ORO_CUSTOMER_CREATE;
463
        } else {
464
            $createEndpoint = SoapTransport::ACTION_CUSTOMER_CREATE;
465
        }
466
467
        return $this->call($createEndpoint, ['customerData' => $customerData]);
468
    }
469
470
    /**
471
     * {@inheritdoc}
472
     */
473
    public function updateCustomer($customerId, array $customerData)
474
    {
475
        if ($this->isSupportedExtensionVersion()) {
476
            $updateEndpoint = SoapTransport::ACTION_ORO_CUSTOMER_UPDATE;
477
        } else {
478
            $updateEndpoint = SoapTransport::ACTION_CUSTOMER_UPDATE;
479
        }
480
481
        return $this->call($updateEndpoint, ['customerId' => $customerId, 'customerData' => $customerData]);
482
    }
483
484
    /**
485
     * {@inheritdoc}
486
     */
487
    public function createCustomerAddress($customerId, array $item)
488
    {
489
        return $this->call(
490
            SoapTransport::ACTION_CUSTOMER_ADDRESS_CREATE,
491
            ['customerId' => $customerId, 'addressData' => $item]
492
        );
493
    }
494
495
    /**
496
     * {@inheritdoc}
497
     */
498
    public function updateCustomerAddress($customerAddressId, array $item)
499
    {
500
        return $this->call(
501
            SoapTransport::ACTION_CUSTOMER_ADDRESS_UPDATE,
502
            ['addressId' => $customerAddressId, 'addressData' => $item]
503
        );
504
    }
505
506
    /**
507
     * {@inheritdoc}
508
     */
509
    public function getCustomerAddressInfo($customerAddressId)
510
    {
511
        if ($this->isSupportedExtensionVersion()) {
512
            $endpoint = SoapTransport::ACTION_ORO_CUSTOMER_ADDRESS_INFO;
513
        } else {
514
            $endpoint = SoapTransport::ACTION_CUSTOMER_ADDRESS_INFO;
515
        }
516
517
        return ConverterUtils::objectToArray($this->call($endpoint, ['addressId' => $customerAddressId]));
518
    }
519
520
    /**
521
     * {@inheritdoc}
522
     */
523
    public function getCustomerInfo($originId)
524
    {
525
        if ($this->isSupportedExtensionVersion()) {
526
            $endpoint = SoapTransport::ACTION_ORO_CUSTOMER_INFO;
527
        } else {
528
            $endpoint = SoapTransport::ACTION_CUSTOMER_INFO;
529
        }
530
531
        return ConverterUtils::objectToArray($this->call($endpoint, ['customerId' => $originId]));
532
    }
533
534
    /**
535
     * {@inheritdoc}
536
     */
537
    public function getNewsletterSubscribers()
538
    {
539
        if ($this->isSupportedExtensionVersion()) {
540
            return new NewsletterSubscriberBridgeIterator($this, $this->settings->all());
541
        }
542
543
        throw new ExtensionRequiredException();
544
    }
545
546
    /**
547
     * {@inheritdoc}
548
     */
549 View Code Duplication
    public function createNewsletterSubscriber(array $subscriberData)
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...
550
    {
551
        if ($this->isExtensionInstalled()) {
552
            $result = $this->call(
553
                SoapTransport::ACTION_ORO_NEWSLETTER_SUBSCRIBER_CREATE,
554
                ['subscriberData' => $subscriberData]
555
            );
556
557
            return ConverterUtils::objectToArray($result);
558
        }
559
560
        throw new ExtensionRequiredException();
561
    }
562
563
    /**
564
     * {@inheritdoc}
565
     */
566 View Code Duplication
    public function updateNewsletterSubscriber($subscriberId, array $subscriberData)
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...
567
    {
568
        if ($this->isExtensionInstalled()) {
569
            $result = $this->call(
570
                SoapTransport::ACTION_ORO_NEWSLETTER_SUBSCRIBER_UPDATE,
571
                ['subscriberId' => $subscriberId, 'subscriberData' => $subscriberData]
572
            );
573
574
            return ConverterUtils::objectToArray($result);
575
        }
576
577
        throw new ExtensionRequiredException();
578
    }
579
580
    /**
581
     * {@inheritdoc}
582
     */
583
    public function getErrorCode(\Exception $e)
584
    {
585
        if ($e instanceof \SoapFault) {
586
            switch ($e->faultcode) {
0 ignored issues
show
Bug introduced by
The property faultcode does not seem to exist in SoapFault.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
587
                case self::SOAP_FAULT_ADDRESS_DOES_NOT_EXIST:
588
                    return self::TRANSPORT_ERROR_ADDRESS_DOES_NOT_EXIST;
589
            }
590
        }
591
    }
592
593
    /**
594
     * {@inheritdoc}
595
     */
596
    public function getLabel()
597
    {
598
        return 'orocrm.magento.transport.soap.label';
599
    }
600
601
    /**
602
     * {@inheritdoc}
603
     */
604
    public function getSettingsFormType()
605
    {
606
        return 'orocrm_magento_soap_transport_setting_form_type';
607
    }
608
609
    /**
610
     * {@inheritdoc}
611
     */
612
    public function getSettingsEntityFQCN()
613
    {
614
        return 'OroCRM\\Bundle\\MagentoBundle\\Entity\\MagentoSoapTransport';
615
    }
616
617
    /**
618
     * Tries to fetch date from response headers
619
     */
620
    protected function lookUpForServerTime()
621
    {
622
        if (null === $this->serverTime) {
623
            $parsedResponse = $this->getLastResponseHeaders();
624
625
            if (isset($parsedResponse['headers']['Date'])) {
626
                $this->serverTime = $parsedResponse['headers']['Date'];
627
            } else {
628
                $this->serverTime = false;
0 ignored issues
show
Documentation Bug introduced by
The property $serverTime was declared of type string, but false is of type false. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
629
            }
630
        }
631
    }
632
}
633