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.

ContactBuilder::buildWithSubscriber()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Gateway\Request;
7
8
use CommerceLeague\ActiveCampaign\Helper\Contants;
9
use Magento\Customer\Api\Data\CustomerInterface as MagentoCustomerInterface;
10
use Magento\Newsletter\Model\Subscriber;
11
12
/**
13
 * Class ContactBuilder
14
 */
15
class ContactBuilder
16
{
17
    /**
18
     * @param MagentoCustomerInterface $magentoCustomer
19
     * @return array
20
     */
21
    public function buildWithMagentoCustomer(MagentoCustomerInterface $magentoCustomer): array
22
    {
23
        $isSubscribed = $magentoCustomer->getExtensionAttributes()->getIsSubscribed();
24
25
        return [
26
            'status' => $isSubscribed ? Contants::CONTACT_STATUS_ACTIVE : Contants::CONTACT_STATUS_UNSUBSCRIBED,
27
            'email' => $magentoCustomer->getEmail(),
28
            'firstName' => $magentoCustomer->getFirstname(),
29
            'lastName' => $magentoCustomer->getLastname()
30
        ];
31
    }
32
33
    /**
34
     * @param Subscriber $subscriber
35
     * @return array
36
     */
37
    public function buildWithSubscriber(Subscriber $subscriber): array
38
    {
39
        $isSubscribed = $subscriber->isSubscribed();
40
41
        return [
42
            'status' => $isSubscribed ? Contants::CONTACT_STATUS_ACTIVE : Contants::CONTACT_STATUS_UNSUBSCRIBED,
43
            'email' => $subscriber->getEmail()
44
        ];
45
    }
46
}
47