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 ( ce7c33...c8c4e6 )
by Andreas
03:55
created

ExportOrderObserver::execute()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 6
c 1
b 0
f 1
nc 3
nop 1
dl 0
loc 15
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Observer\Sales;
7
8
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
9
use CommerceLeague\ActiveCampaign\Service\ExportOrderService;
10
use Magento\Framework\Event\Observer;
11
use Magento\Framework\Event\ObserverInterface;
12
use Magento\Sales\Model\Order as MagentoOrder;
13
14
/**
15
 * Class ExportOrderObserver
16
 */
17
class ExportOrderObserver implements ObserverInterface
18
{
19
    /**
20
     * @var ConfigHelper
21
     */
22
    private $configHelper;
23
24
    /**
25
     * @var ExportOrderService
26
     */
27
    private $exportOrderService;
28
29
    /**
30
     * @param ConfigHelper $configHelper
31
     * @param ExportOrderService $exportOrderService
32
     */
33
    public function __construct(
34
        ConfigHelper $configHelper,
35
        ExportOrderService $exportOrderService
36
    ) {
37
        $this->configHelper = $configHelper;
38
        $this->exportOrderService = $exportOrderService;
39
    }
40
41
    /**
42
     * @inheritDoc
43
     */
44
    public function execute(Observer $observer)
45
    {
46
        if (!$this->configHelper->isApiEnabled()) {
47
            return;
48
        }
49
50
        /** @var MagentoOrder $magentoOrder */
51
        $magentoOrder = $observer->getEvent()->getData('order');
52
53
        // do not export guest orders for now
54
        if ($magentoOrder->getStatus() !== MagentoOrder::STATE_COMPLETE || $magentoOrder->getCustomerIsGuest()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $magentoOrder->getCustomerIsGuest() of type integer|null is loosely compared to true; this is ambiguous if the integer can be 0. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
55
            return;
56
        }
57
58
        $this->exportOrderService->export($magentoOrder);
59
    }
60
}
61