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 ( f9a184...b81ec7 )
by Andreas
04:10
created

ExportContactObserver::execute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 14
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Observer\Newsletter;
7
8
use CommerceLeague\ActiveCampaign\Service\ExportContactService;
9
use Magento\Framework\Event\Observer;
10
use Magento\Framework\Event\ObserverInterface;
11
use Magento\Newsletter\Model\Subscriber;
12
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
13
14
/**
15
 * Class ExportContactObserver
16
 */
17
class ExportContactObserver implements ObserverInterface
18
{
19
    /**
20
     * @var ConfigHelper
21
     */
22
    private $configHelper;
23
24
    /**
25
     * @var ExportContactService
26
     */
27
    private $exportContactService;
28
29
    /**
30
     * @param ConfigHelper $configHelper
31
     * @param ExportContactService $exportContactService
32
     */
33
    public function __construct(
34
        ConfigHelper $configHelper,
35
        ExportContactService $exportContactService
36
    ) {
37
        $this->configHelper = $configHelper;
38
        $this->exportContactService = $exportContactService;
39
    }
40
41
    /**
42
     * @inheritDoc
43
     */
44
    public function execute(Observer $observer)
45
    {
46
        if (!$this->configHelper->isApiEnabled()) {
47
            return;
48
        }
49
50
        /** @var Subscriber $subscriber */
51
        $subscriber = $observer->getEvent()->getData('subscriber');
52
53
        if ($subscriber->getData('customer_id')) {
54
            return;
55
        }
56
57
        $this->exportContactService->exportWithSubscriber($subscriber);
58
    }
59
}
60