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 ( a2b3b2...f1cd39 )
by Andreas
03:20
created

SyncCustomerObserver::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 15
rs 10
c 1
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Observer\Customer;
7
8
use CommerceLeague\ActiveCampaign\Gateway\Request\CustomerBuilder as CustomerRequestBuilder;
9
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
10
use CommerceLeague\ActiveCampaign\MessageQueue\Topics;
11
use Magento\Customer\Model\Customer;
12
use Magento\Framework\Event\Observer;
13
use Magento\Framework\Event\ObserverInterface;
14
use Magento\Framework\MessageQueue\PublisherInterface;
15
16
/**
17
 * Class SyncCustomerObserver
18
 */
19
class SyncCustomerObserver implements ObserverInterface
20
{
21
    /**
22
     * @var ConfigHelper
23
     */
24
    private $configHelper;
25
26
    /**
27
     * @var CustomerRequestBuilder
28
     */
29
    private $customerRequestBuilder;
30
31
    /**
32
     * @var PublisherInterface
33
     */
34
    private $publisher;
35
36
    /**
37
     * @param ConfigHelper $configHelper
38
     * @param CustomerRequestBuilder $customerRequestBuilder
39
     * @param PublisherInterface $publisher
40
     */
41
    public function __construct(
42
        ConfigHelper $configHelper,
43
        CustomerRequestBuilder $customerRequestBuilder,
44
        PublisherInterface $publisher
45
    ) {
46
        $this->configHelper = $configHelper;
47
        $this->customerRequestBuilder = $customerRequestBuilder;
48
        $this->publisher = $publisher;
49
    }
50
51
    /**
52
     * @inheritDoc
53
     */
54
    public function execute(Observer $observer)
55
    {
56
        if (!$this->configHelper->isApiEnabled()) {
57
            return;
58
        }
59
60
        /** @var Customer $magentoCustomer */
61
        $magentoCustomer = $observer->getEvent()->getData('customer');
62
63
        $data = [
64
            'magento_customer_id' => $magentoCustomer->getId(),
65
            'request' => $this->customerRequestBuilder->build($magentoCustomer)
66
        ];
67
68
        $this->publisher->publish(Topics::CUSTOMER_SYNC, json_encode($data));
0 ignored issues
show
Bug introduced by
json_encode($data) of type string is incompatible with the type array|object expected by parameter $data of Magento\Framework\Messag...herInterface::publish(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

68
        $this->publisher->publish(Topics::CUSTOMER_SYNC, /** @scrutinizer ignore-type */ json_encode($data));
Loading history...
69
    }
70
}
71