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 ( a4bd13...c92bdf )
by Andreas
03:29
created

Collection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 9
c 1
b 0
f 1
nc 1
nop 8
dl 0
loc 19
rs 9.9666

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Model\ResourceModel\Quote;
7
8
use CommerceLeague\ActiveCampaign\Setup\SchemaInterface;
9
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
10
use Magento\Framework\Data\Collection\EntityFactoryInterface;
11
use Magento\Framework\DB\Adapter\AdapterInterface;
12
use Magento\Framework\Event\ManagerInterface;
13
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
14
use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot;
15
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
16
use Magento\Quote\Model\ResourceModel\Quote\Collection as ExtendCollection;
17
use Psr\Log\LoggerInterface;
18
19
/**
20
 * Class Collection
21
 * @codeCoverageIgnore
22
 */
23
class Collection extends ExtendCollection
24
{
25
    /**
26
     * @var TimezoneInterface
27
     */
28
    private $timezone;
29
30
    /**
31
     * @param EntityFactoryInterface $entityFactory
32
     * @param LoggerInterface $logger
33
     * @param FetchStrategyInterface $fetchStrategy
34
     * @param ManagerInterface $eventManager
35
     * @param Snapshot $entitySnapshot
36
     * @param TimezoneInterface $timezone
37
     * @param AdapterInterface|null $connection
38
     * @param AbstractDb|null $resource
39
     */
40
    public function __construct(
41
        EntityFactoryInterface $entityFactory,
42
        LoggerInterface $logger,
43
        FetchStrategyInterface $fetchStrategy,
44
        ManagerInterface $eventManager,
45
        Snapshot $entitySnapshot,
46
        TimezoneInterface $timezone,
47
        AdapterInterface $connection = null,
48
        AbstractDb $resource = null
49
    ) {
50
        $this->timezone = $timezone;
51
        parent::__construct(
52
            $entityFactory,
53
            $logger,
54
            $fetchStrategy,
55
            $eventManager,
56
            $entitySnapshot,
57
            $connection,
58
            $resource
59
        );
60
    }
61
62
    /**
63
     * @inheritDoc
64
     */
65
    protected function _initSelect()
66
    {
67
        parent::_initSelect();
68
69
        $this->getSelect()->joinLeft(
70
            ['ac_order' => $this->_resource->getTable(SchemaInterface::ORDER_TABLE)],
0 ignored issues
show
Unused Code introduced by
The call to Magento\Framework\DB\Select::joinLeft() has too many arguments starting with array('ac_order' => $thi...nterface::ORDER_TABLE)). ( Ignorable by Annotation )

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

70
        $this->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...
71
            'ac_order.magento_quote_id = main_table.entity_id',
72
            ['ac_order.activecampaign_id']
73
        );
74
75
        return $this;
76
    }
77
78
    /**
79
     * @return Collection
80
     * @throws \Exception
81
     */
82
    public function addAbandonedFilter(): self
83
    {
84
        $this->getSelect()->where('main_table.items_count != 0');
85
        $this->getSelect()->where('main_table.is_active = 1');
86
        $this->getSelect()->where('main_table.customer_id IS NOT NULL');
87
88
        $fromDateTime = $this->timezone->date()
89
            ->sub(new \DateInterval('PT1H'))
90
            ->format('Y-m-d H:i:s');
91
92
        $this->getSelect()->where('main_table.updated_at <= ?', $fromDateTime);
93
94
        return $this;
95
    }
96
97
    /**
98
     * @param int $quoteId
99
     * @return Collection
100
     */
101
    public function addIdFilter(int $quoteId): self
102
    {
103
        $this->getSelect()->where('main_table.entity_id = ?', $quoteId);
104
        return $this;
105
    }
106
107
    /**
108
     * @return Collection
109
     */
110
    public function addOmittedFilter(): self
111
    {
112
        $this->getSelect()->where('ac_order.activecampaign_id IS NULL');
113
        return $this;
114
    }
115
}
116