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 ( f51f95...468920 )
by Andreas
03:39
created

AbandonedCart   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 30
c 1
b 0
f 1
dl 0
loc 69
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getExportCollection() 0 38 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Helper;
7
8
use Magento\Framework\App\Helper\AbstractHelper;
9
use Magento\Framework\App\Helper\Context;
10
use Magento\Quote\Model\ResourceModel\Quote\CollectionFactory as QuoteCollectionFactory;
0 ignored issues
show
Bug introduced by
The type Magento\Quote\Model\Reso...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...
11
use Magento\Quote\Model\ResourceModel\Quote\Collection as QuoteCollection;
12
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
13
14
/**
15
 * Class AbandonedCart
16
 */
17
class AbandonedCart extends AbstractHelper
18
{
19
    /**
20
     * @var QuoteCollectionFactory
21
     */
22
    private $quoteCollectionFactory;
23
24
    /**
25
     * @var ConfigHelper
26
     */
27
    private $configHelper;
28
29
    /**
30
     * @param Context $context
31
     * @param QuoteCollectionFactory $quoteCollectionFactory
32
     * @param Config $configHelper
33
     */
34
    public function __construct(
35
        Context $context,
36
        QuoteCollectionFactory $quoteCollectionFactory,
37
        ConfigHelper $configHelper
38
    ) {
39
        $this->quoteCollectionFactory = $quoteCollectionFactory;
40
        $this->configHelper = $configHelper;
41
        parent::__construct($context);
42
    }
43
44
    /**
45
     * @return QuoteCollection
46
     * @throws \Exception
47
     */
48
    public function getExportCollection(): QuoteCollection
49
    {
50
        /** @var QuoteCollection $quoteCollection */
51
        $quoteCollection = $this->quoteCollectionFactory->create();
52
53
        $quoteCollection->addFieldToFilter(
54
            'items_count',
55
            ['neq' => '0']
56
        )->addFieldToFilter(
57
            'main_table.is_active',
58
            '1'
59
        )->addFieldToFilter(
60
            'main_table.customer_id',
61
            ['neq' => null]
62
        );
63
64
        $minutes = (int)$this->configHelper->getAbandonedCartExportAfter();
65
66
        $maxUpdatedAtTime = new \DateTime('now', new \DateTimeZone('UTC'));
67
        $interval = new \DateInterval(sprintf('PT%sM', $minutes));
68
        $maxUpdatedAtTime->sub($interval);
69
70
        $quoteCollection->addFieldToFilter(
71
            'main_table.updated_at',
72
            ['lteq' => $maxUpdatedAtTime->format('Y-m-d H:i:s')]
73
        );
74
75
        $quoteCollection->getSelect()->joinLeft(
76
            $quoteCollection->getSelect()->getConnection()->getTableName('activecampaign_abandoned'),
0 ignored issues
show
Unused Code introduced by
The call to Magento\Framework\DB\Select::joinLeft() has too many arguments starting with $quoteCollection->getSel...ivecampaign_abandoned'). ( Ignorable by Annotation )

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

76
        $quoteCollection->getSelect()->/** @scrutinizer ignore-call */ joinLeft(

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
77
            'main_table.entity_id = activecampaign_abandoned.quote_id'
78
        );
79
80
        $quoteCollection->addFieldToFilter(
81
            'activecampaign_abandoned.activecampaign_id',
82
            ['null' => true]
83
        );
84
85
        return $quoteCollection;
86
    }
87
}
88