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

ExportOmittedAbandonedCarts::getQuoteIds()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Cron;
7
8
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
9
use CommerceLeague\ActiveCampaign\MessageQueue\Topics;
10
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Quote\Collection as QuoteCollection;
11
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Quote\CollectionFactory as QuoteCollectionFactory;
0 ignored issues
show
Bug introduced by
The type CommerceLeague\ActiveCam...Quote\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...
12
use Magento\Framework\MessageQueue\PublisherInterface;
13
14
/**
15
 * Class ExportOmittedAbandonedCarts
16
 */
17
class ExportOmittedAbandonedCarts implements CronInterface
18
{
19
    /**
20
     * @var ConfigHelper
21
     */
22
    private $configHelper;
23
24
    /**
25
     * @var QuoteCollectionFactory
26
     */
27
    private $quoteCollectionFactory;
28
29
    /**
30
     * @var PublisherInterface
31
     */
32
    private $publisher;
33
34
    /**
35
     * @param ConfigHelper $configHelper
36
     * @param QuoteCollectionFactory $quoteCollectionFactory
37
     * @param PublisherInterface $publisher
38
     */
39
    public function __construct(
40
        ConfigHelper $configHelper,
41
        QuoteCollectionFactory $quoteCollectionFactory,
42
        PublisherInterface $publisher
43
    ) {
44
        $this->configHelper = $configHelper;
45
        $this->quoteCollectionFactory = $quoteCollectionFactory;
46
        $this->publisher = $publisher;
47
    }
48
49
    /**
50
     * @throws \Exception
51
     */
52
    public function run(): void
53
    {
54
        if (!$this->configHelper->isEnabled() || !$this->configHelper->isAbandonedCartExportEnabled()) {
55
            return;
56
        }
57
58
        $quoteIds = $this->getQuoteIds();
59
60
        foreach ($quoteIds as $quoteId) {
61
            $this->publisher->publish(
62
                Topics::QUOTE_ABANDONED_CART_EXPORT,
63
                json_encode(['quote_id' => $quoteId])
0 ignored issues
show
Bug introduced by
json_encode(array('quote_id' => $quoteId)) 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

63
                /** @scrutinizer ignore-type */ json_encode(['quote_id' => $quoteId])
Loading history...
64
            );
65
        }
66
    }
67
68
    /**
69
     * @return array
70
     * @throws \Exception
71
     */
72
    private function getQuoteIds(): array
73
    {
74
        /** @var QuoteCollection $quoteCollection */
75
        $quoteCollection = $this->quoteCollectionFactory->create();
76
        $quoteCollection->addAbandonedFilter();
77
        $quoteCollection->addOmittedFilter();
78
79
        return $quoteCollection->getAllIds();
80
    }
81
}
82