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

SyncContactService::syncWithMagentoCustomer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Service\Contact;
7
8
use CommerceLeague\ActiveCampaign\Gateway\Request\ContactBuilder as ContactRequestBuilder;
9
use CommerceLeague\ActiveCampaign\MessageQueue\Topics;
10
use Magento\Customer\Model\Customer as MagentoCustomer;
11
use Magento\Framework\MessageQueue\PublisherInterface;
12
use Magento\Newsletter\Model\Subscriber;
13
14
class SyncContactService
15
{
16
    /**
17
     * @var ContactRequestBuilder
18
     */
19
    private $contactRequestBuilder;
20
21
    /**
22
     * @var PublisherInterface
23
     */
24
    private $publisher;
25
26
    /**
27
     * @param ContactRequestBuilder $contactRequestBuilder
28
     * @param PublisherInterface $publisher
29
     */
30
    public function __construct(
31
        ContactRequestBuilder $contactRequestBuilder,
32
        PublisherInterface $publisher
33
    ) {
34
        $this->contactRequestBuilder = $contactRequestBuilder;
35
        $this->publisher = $publisher;
36
    }
37
38
    /**
39
     * @param MagentoCustomer $magentoCustomer
40
     */
41
    public function syncWithMagentoCustomer(MagentoCustomer $magentoCustomer): void
42
    {
43
        $data = [
44
            'email' => $magentoCustomer->getData('email'),
45
            'request' => $this->contactRequestBuilder->buildWithMagentoCustomer($magentoCustomer)
46
        ];
47
48
        $this->publisher->publish(Topics::CONTACT_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

48
        $this->publisher->publish(Topics::CONTACT_SYNC, /** @scrutinizer ignore-type */ json_encode($data));
Loading history...
49
    }
50
51
    /**
52
     * @param Subscriber $subscriber
53
     */
54
    public function syncWithSubscriber(Subscriber $subscriber): void
55
    {
56
        $data = [
57
            'email' => $subscriber->getEmail(),
58
            'request' => $this->contactRequestBuilder->buildWithSubscriber($subscriber)
59
        ];
60
61
        $this->publisher->publish(Topics::CONTACT_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

61
        $this->publisher->publish(Topics::CONTACT_SYNC, /** @scrutinizer ignore-type */ json_encode($data));
Loading history...
62
    }
63
}
64