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.
Passed
Push — master ( 3bfcba...f91474 )
by Andreas
04:15
created

CreateUpdateMessageBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\MessageQueue\Contact;
7
8
use CommerceLeague\ActiveCampaign\Api\Data\ContactInterface;
9
use Magento\Customer\Model\Customer;
10
use Magento\Newsletter\Model\Subscriber;
11
12
/**
13
 * Class CreateUpdateMessageBuilder
14
 */
15
class CreateUpdateMessageBuilder
16
{
17
    /**
18
     * @var CreateUpdateMessageFactory
0 ignored issues
show
Bug introduced by
The type CommerceLeague\ActiveCam...ateUpdateMessageFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
     */
20
    private $createUpdateMessageFactory;
21
22
    /**
23
     * @param CreateUpdateMessageFactory $createUpdateMessageFactory
24
     */
25
    public function __construct(CreateUpdateMessageFactory $createUpdateMessageFactory)
26
    {
27
        $this->createUpdateMessageFactory = $createUpdateMessageFactory;
28
    }
29
30
    /**
31
     * @param ContactInterface $contact
32
     * @param Customer $customer
33
     * @return CreateUpdateMessage
34
     */
35
    public function buildWithCustomer(ContactInterface $contact, Customer $customer): CreateUpdateMessage
36
    {
37
        $request = [
38
            'email' => $customer->getData('email'),
39
            'firstName' => $customer->getData('firstname'),
40
            'lastName' => $customer->getData('lastname')
41
        ];
42
43
        /** @var CreateUpdateMessage $message */
44
        $message = $this->createUpdateMessageFactory->create();
45
46
        $message->setContactId((int)$contact->getId())
47
            ->setSerializedRequest(json_encode($request));
48
49
        return $message;
50
    }
51
52
    /**
53
     * @param ContactInterface $contact
54
     * @param Subscriber $subscriber
55
     * @return CreateUpdateMessage
56
     */
57
    public function buildWithSubscriber(ContactInterface $contact, Subscriber $subscriber): CreateUpdateMessage
58
    {
59
        $request =  [
60
            'email' => $subscriber->getEmail()
61
        ];
62
63
        /** @var CreateUpdateMessage $message */
64
        $message = $this->createUpdateMessageFactory->create();
65
66
        $message->setContactId((int)$contact->getId())
67
            ->setSerializedRequest(json_encode($request));
68
69
        return $message;
70
    }
71
}
72