Issues (139)

Cron/FetchTransactionOrderGetpay.php (1 issue)

1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
9
namespace Getnet\PaymentMagento\Cron;
10
11
use Getnet\PaymentMagento\Gateway\Config\ConfigGetpay;
12
use Magento\Payment\Model\Method\Logger;
13
use Magento\Sales\Model\Order;
14
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
15
16
/*
17
 * Class Fetch Transaction Order Getpay - Cron fetch order
18
 */
19
class FetchTransactionOrderGetpay
20
{
21
    /**
22
     * @var Logger
23
     */
24
    protected $logger;
25
26
    /**
27
     * @var Order
28
     */
29
    protected $order;
30
31
    /**
32
     * @var ConfigGetpay
33
     */
34
    protected $configGetpay;
35
36
    /**
37
     * @var CollectionFactory
38
     */
39
    protected $collectionFactory;
40
41
    /**
42
     * @param Order             $order
43
     * @param Logger            $logger
44
     * @param ConfigGetpay      $configGetpay
45
     * @param CollectionFactory $collectionFactory
46
     */
47
    public function __construct(
48
        Order $order,
49
        Logger $logger,
50
        ConfigGetpay $configGetpay,
51
        CollectionFactory $collectionFactory
52
    ) {
53
        $this->order = $order;
54
        $this->logger = $logger;
55
        $this->configGetpay = $configGetpay;
56
        $this->collectionFactory = $collectionFactory;
57
    }
58
59
    /**
60
     * Execute.
61
     *
62
     * @return void
63
     */
64
    public function execute()
65
    {
66
        $orders = $this->collectionFactory->create()
67
        ->addFieldToFilter('state', [
68
            'in' => [
69
                Order::STATE_NEW,
70
            ],
71
        ]);
72
73
        $orders->getSelect()
74
                ->join(
75
                    ['sop' => 'sales_order_payment'],
0 ignored issues
show
The call to Magento\Framework\DB\Select::join() has too many arguments starting with array('sop' => 'sales_order_payment'). ( Ignorable by Annotation )

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

75
                ->/** @scrutinizer ignore-call */ join(

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...
76
                    'main_table.entity_id = sop.parent_id',
77
                    ['method']
78
                )
79
                ->where('sop.method = ?', ConfigGetpay::METHOD);
80
81
        foreach ($orders as $order) {
82
            if (!$order->getEntityId()) {
83
                continue;
84
            }
85
            $loadedOrder = $this->order->load($order->getEntityId());
86
            $payment = $loadedOrder->getPayment();
87
            $payment->update();
88
            $this->logger->debug([
89
                'cron'   => 'FetchTransactionOrderGetpay',
90
                'type'   => ConfigGetpay::METHOD,
91
                'order'  => $loadedOrder->getIncrementId(),
92
                'status' => $loadedOrder->getStatus(),
93
            ]);
94
        }
95
    }
96
}
97