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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildWithMagentoCustomer() 0 9 2
A buildWithSubscriber() 0 7 2
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