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 ( d8327a...c6d836 )
by Andreas
03:23
created

CreateMessageBuilder::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 16
rs 9.9666
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\MessageQueue\Customer;
7
8
use CommerceLeague\ActiveCampaign\Api\Data\CustomerInterface;
9
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
10
use Magento\Customer\Model\Customer as MagentoCustomer;
11
12
class CreateMessageBuilder
13
{
14
    /**
15
     * @var ConfigHelper
16
     */
17
    private $configHelper;
18
19
    /**
20
     * @var CreateMessageFactory
0 ignored issues
show
Bug introduced by
The type CommerceLeague\ActiveCam...er\CreateMessageFactory 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...
21
     */
22
    private $createMessageFactory;
23
24
    /**
25
     * @param ConfigHelper $configHelper
26
     * @param CreateMessageFactory $createMessageFactory
27
     */
28
    public function __construct(
29
        ConfigHelper $configHelper,
30
        CreateMessageFactory $createMessageFactory
31
    ) {
32
        $this->createMessageFactory = $createMessageFactory;
33
        $this->configHelper = $configHelper;
34
    }
35
36
    /**
37
     * @param CustomerInterface $customer
38
     * @param MagentoCustomer $magentoCustomer
39
     * @return CreateMessage
40
     */
41
    public function build(CustomerInterface $customer, MagentoCustomer $magentoCustomer): CreateMessage
42
    {
43
        $request = [
44
            'connectionid' => $this->configHelper->getConnectionId(),
45
            'externalid' => $magentoCustomer->getId(),
46
            'email' => $magentoCustomer->getData('email'),
47
            'acceptsMarketing' => 1 // TODO::check how this value could be set
48
        ];
49
50
        /** @var CreateMessage $message */
51
        $message = $this->createMessageFactory->create();
52
53
        $message->setEntityId((int)$customer->getId())
54
            ->setSerializedRequest(json_encode($request));
55
56
        return $message;
57
    }
58
}
59