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.

Issues (203)

Model/ActiveCampaign/OrderRepository.php (2 issues)

1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Model\ActiveCampaign;
7
8
use CommerceLeague\ActiveCampaign\Api\Data;
9
use CommerceLeague\ActiveCampaign\Api\OrderRepositoryInterface;
10
use CommerceLeague\ActiveCampaign\Model\ResourceModel\ActiveCampaign\Order as OrderResource;
11
use Magento\Framework\Exception\CouldNotDeleteException;
12
use Magento\Framework\Exception\CouldNotSaveException;
13
use Magento\Framework\Exception\NoSuchEntityException;
14
use Magento\Framework\Model\AbstractModel;
15
16
class OrderRepository implements OrderRepositoryInterface
17
{
18
    /**
19
     * @var OrderResource
20
     */
21
    private $orderResource;
22
23
    /**
24
     * @var OrderFactory
0 ignored issues
show
The type CommerceLeague\ActiveCam...veCampaign\OrderFactory 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...
25
     */
26
    private $orderFactory;
27
28
    /**
29
     * @param OrderResource $orderResource
30
     * @param OrderFactory $orderFactory
31
     */
32
    public function __construct(
33
        OrderResource $orderResource,
34
        OrderFactory $orderFactory
35
    ) {
36
        $this->orderResource = $orderResource;
37
        $this->orderFactory = $orderFactory;
38
    }
39
40
    /**
41
     * @param Data\OrderInterface|AbstractModel $order
42
     * @return Data\OrderInterface
43
     * @throws CouldNotSaveException
44
     */
45
    public function save(Data\OrderInterface $order): Data\OrderInterface
46
    {
47
        try {
48
            $this->orderResource->save($order);
49
        } catch (\Exception $e) {
50
            throw new CouldNotSaveException(__($e->getMessage()));
51
        }
52
53
        return $order;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $order returns the type Magento\Framework\Model\AbstractModel which is incompatible with the type-hinted return CommerceLeague\ActiveCam...Api\Data\OrderInterface.
Loading history...
54
    }
55
56
    /**
57
     * @inheritDoc
58
     */
59
    public function getById($entityId): Data\OrderInterface
60
    {
61
        /** @var Order $order */
62
        $order = $this->orderFactory->create();
63
        $this->orderResource->load($order, $entityId);
64
65
        return $order;
66
    }
67
68
    /**
69
     * @inheritDoc
70
     */
71
    public function getByMagentoQuoteId($magentoQuoteId): Data\OrderInterface
72
    {
73
        /** @var Order $order */
74
        $order = $this->orderFactory->create();
75
        $this->orderResource->load(
76
            $order,
77
            $magentoQuoteId,
78
            Data\OrderInterface::MAGENTO_QUOTE_ID
79
        );
80
81
        return $order;
82
    }
83
84
    /**
85
     * @inheritDoc
86
     */
87
    public function getOrCreateByMagentoQuoteId($magentoQuoteId): Data\OrderInterface
88
    {
89
        $order = $this->getByMagentoQuoteId($magentoQuoteId);
90
91
        if (!$order->getId()) {
92
            $order->setMagentoQuoteId($magentoQuoteId);
93
            $this->save($order);
94
        }
95
96
        return $order;
97
    }
98
99
    /**
100
     * @param Data\OrderInterface|AbstractModel $order
101
     * @return bool
102
     * @throws CouldNotDeleteException
103
     */
104
    public function delete(Data\OrderInterface $order): bool
105
    {
106
        try {
107
            $this->orderResource->delete($order);
108
        } catch (\Exception $e) {
109
            throw new CouldNotDeleteException(__($e->getMessage()));
110
        }
111
112
        return true;
113
    }
114
115
    /**
116
     * @inheritDoc
117
     */
118
    public function deleteById($entityId): bool
119
    {
120
        $order = $this->getById($entityId);
121
122
        if (!$order->getId()) {
123
            throw new NoSuchEntityException(
124
                __('The Order with the "%1" ID doesn\'t exist', $entityId)
125
            );
126
        }
127
128
        return $this->delete($order);
129
    }
130
}
131