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 ( 416677...d8aab5 )
by Andreas
03:56
created

ExportOmittedCustomers   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 17
c 1
b 0
f 1
dl 0
loc 61
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCustomerIds() 0 7 1
A __construct() 0 8 1
A run() 0 12 4
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Cron;
7
8
9
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
10
use CommerceLeague\ActiveCampaign\MessageQueue\Topics;
11
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Customer\Collection as CustomerCollection;
12
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory;
0 ignored issues
show
Bug introduced by
The type CommerceLeague\ActiveCam...tomer\CollectionFactory 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...
13
use Magento\Framework\MessageQueue\PublisherInterface;
14
15
/**
16
 * Class ExportOmittedCustomers
17
 */
18
class ExportOmittedCustomers implements CronInterface
19
{
20
    /**
21
     * @var ConfigHelper
22
     */
23
    private $configHelper;
24
25
    /**
26
     * @var CustomerCollectionFactory
27
     */
28
    private $customerCollectionFactory;
29
30
    /**
31
     * @var PublisherInterface
32
     */
33
    private $publisher;
34
35
    /**
36
     * @param ConfigHelper $configHelper
37
     * @param CustomerCollectionFactory $customerCollectionFactory
38
     * @param PublisherInterface $publisher
39
     */
40
    public function __construct(
41
        ConfigHelper $configHelper,
42
        CustomerCollectionFactory $customerCollectionFactory,
43
        PublisherInterface $publisher
44
    ) {
45
        $this->configHelper = $configHelper;
46
        $this->customerCollectionFactory = $customerCollectionFactory;
47
        $this->publisher = $publisher;
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53
    public function run(): void
54
    {
55
        if (!$this->configHelper->isEnabled() || !$this->configHelper->isCustomerExportEnabled()) {
56
            return;
57
        }
58
59
        $customerIds = $this->getCustomerIds();
60
61
        foreach ($customerIds as $customerId) {
62
            $this->publisher->publish(
63
                Topics::CUSTOMER_CUSTOMER_EXPORT,
64
                json_encode(['magento_customer_id' => $customerId])
0 ignored issues
show
Bug introduced by
json_encode(array('magen...er_id' => $customerId)) of type string is incompatible with the type array|object expected by parameter $data of Magento\Framework\Messag...herInterface::publish(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

64
                /** @scrutinizer ignore-type */ json_encode(['magento_customer_id' => $customerId])
Loading history...
65
            );
66
        }
67
    }
68
69
    /**
70
     * @return array
71
     */
72
    private function getCustomerIds(): array
73
    {
74
        /** @var CustomerCollection $customerCollection */
75
        $customerCollection = $this->customerCollectionFactory->create();
76
        $customerCollection->addCustomerOmittedFilter();
77
78
        return $customerCollection->getAllIds();
79
    }
80
}
81