Passed
Push — feature/eco-2295/master ( c16d9a...3e2e74 )
by Aleksey
03:06
created

CrefoPayRepository::getPaymentCrefoPayQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\CrefoPay\Persistence;
9
10
use Generated\Shared\Transfer\PaymentCrefoPayOrderItemCollectionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...rItemCollectionTransfer 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 Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...oCrefoPayApiLogTransfer 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 Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...PayNotificationTransfer 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...
13
use Generated\Shared\Transfer\PaymentCrefoPayTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentCrefoPayTransfer 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...
14
use Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayOrderItemQuery;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\CrefoPay\Persist...tCrefoPayOrderItemQuery 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...
15
use Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayOrderItemToCrefoPayApiLogQuery;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\CrefoPay\Persist...emToCrefoPayApiLogQuery 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...
16
use Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayOrderItemToCrefoPayNotificationQuery;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\CrefoPay\Persist...efoPayNotificationQuery 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...
17
use Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayQuery;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\CrefoPay\Persist...SpyPaymentCrefoPayQuery 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...
18
use Spryker\Zed\Kernel\Persistence\AbstractRepository;
19
use SprykerEco\Zed\CrefoPay\Persistence\Mapper\CrefoPayPersistenceMapper;
20
21
/**
22
 * @method \SprykerEco\Zed\CrefoPay\Persistence\CrefoPayPersistenceFactory getFactory()
23
 */
24
class CrefoPayRepository extends AbstractRepository implements CrefoPayRepositoryInterface
25
{
26
    /**
27
     * @param int $idSalesOrder
28
     *
29
     * @return \Generated\Shared\Transfer\PaymentCrefoPayTransfer|null
30
     */
31
    public function findPaymentCrefoPayByIdSalesOrder(int $idSalesOrder): ?PaymentCrefoPayTransfer
32
    {
33
        $paymentCrefoPayEntity = $this->getPaymentCrefoPayQuery()
34
            ->filterByFkSalesOrder($idSalesOrder)
35
            ->findOne();
36
37
        if ($paymentCrefoPayEntity === null) {
38
            return null;
39
        }
40
41
        return $this->getMapper()
42
            ->mapEntityToPaymentCrefoPayTransfer($paymentCrefoPayEntity, new PaymentCrefoPayTransfer());
43
    }
44
45
    /**
46
     * @param string $crefoPayOrderId
47
     *
48
     * @return \Generated\Shared\Transfer\PaymentCrefoPayTransfer|null
49
     */
50
    public function findPaymentCrefoPayByCrefoPayOrderId(string $crefoPayOrderId): ?PaymentCrefoPayTransfer
51
    {
52
        $paymentCrefoPayEntity = $this->getPaymentCrefoPayQuery()
53
            ->filterByCrefoPayOrderId($crefoPayOrderId)
54
            ->findOne();
55
56
        if ($paymentCrefoPayEntity === null) {
57
            return null;
58
        }
59
60
        return $this->getMapper()
61
            ->mapEntityToPaymentCrefoPayTransfer($paymentCrefoPayEntity, new PaymentCrefoPayTransfer());
62
    }
63
64
    /**
65
     * @param int $idSalesOrderItem
66
     *
67
     * @return \Generated\Shared\Transfer\PaymentCrefoPayTransfer|null
68
     */
69
    public function findPaymentCrefoPayByIdSalesOrderItem(int $idSalesOrderItem): ?PaymentCrefoPayTransfer
70
    {
71
        /** @var \Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPay|null $paymentCrefoPayEntity */
72
        $paymentCrefoPayEntity = $this->getPaymentCrefoPayQuery()
73
            ->useSpyPaymentCrefoPayOrderItemQuery()
74
                ->filterByFkSalesOrderItem($idSalesOrderItem)
75
            ->endUse()
76
            ->findOne();
77
78
        if ($paymentCrefoPayEntity === null) {
79
            return null;
80
        }
81
82
        return $this->getMapper()
83
            ->mapEntityToPaymentCrefoPayTransfer($paymentCrefoPayEntity, new PaymentCrefoPayTransfer());
84
    }
85
86
    /**
87
     * @param string $crefoPayOrderId
88
     *
89
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemCollectionTransfer
90
     */
91
    public function getPaymentCrefoPayOrderItemCollectionByCrefoPayOrderId(string $crefoPayOrderId): PaymentCrefoPayOrderItemCollectionTransfer
92
    {
93
        /** @var \Propel\Runtime\Collection\ObjectCollection|\Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayOrderItem[] $paymentCrefoPayOrderItemEntities */
94
        $paymentCrefoPayOrderItemEntities = $this->getPaymentCrefoPayOrderItemQuery()
95
            ->useSpyPaymentCrefoPayQuery()
96
                ->filterByCrefoPayOrderId($crefoPayOrderId)
97
            ->endUse()
98
            ->find();
99
100
        return $this->getMapper()
101
            ->mapOrderItemEntitiesToOrderItemCollection(
102
                $paymentCrefoPayOrderItemEntities,
103
                new PaymentCrefoPayOrderItemCollectionTransfer()
104
            );
105
    }
106
107
    /**
108
     * @param string $captureId
109
     *
110
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemCollectionTransfer
111
     */
112
    public function getPaymentCrefoPayOrderItemCollectionByCaptureId(string $captureId): PaymentCrefoPayOrderItemCollectionTransfer
113
    {
114
        /** @var \Propel\Runtime\Collection\ObjectCollection|\Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayOrderItem[] $paymentCrefoPayOrderItemEntities */
115
        $paymentCrefoPayOrderItemEntities = $this->getPaymentCrefoPayOrderItemQuery()
116
            ->filterByCaptureId($captureId)
117
            ->find();
118
119
        return $this->getMapper()
120
            ->mapOrderItemEntitiesToOrderItemCollection(
121
                $paymentCrefoPayOrderItemEntities,
122
                new PaymentCrefoPayOrderItemCollectionTransfer()
123
            );
124
    }
125
126
    /**
127
     * @param int[] $salesOrderItemIds
128
     *
129
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemCollectionTransfer
130
     */
131
    public function getPaymentCrefoPayOrderItemCollectionBySalesOrderItemIds(array $salesOrderItemIds): PaymentCrefoPayOrderItemCollectionTransfer
132
    {
133
        /** @var \Propel\Runtime\Collection\ObjectCollection|\Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayOrderItem[] $paymentCrefoPayOrderItemEntities */
134
        $paymentCrefoPayOrderItemEntities = $this->getPaymentCrefoPayOrderItemQuery()
135
            ->filterByFkSalesOrderItem_In($salesOrderItemIds)
136
            ->find();
137
138
        return $this->getMapper()
139
            ->mapOrderItemEntitiesToOrderItemCollection(
140
                $paymentCrefoPayOrderItemEntities,
141
                new PaymentCrefoPayOrderItemCollectionTransfer()
142
            );
143
    }
144
145
    /**
146
     * @param int $idSalesOrderItem
147
     * @param string $apiLogRequestType
148
     * @param int[] $resultCodes
149
     *
150
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer|null
151
     */
152
    public function findPaymentCrefoPayOrderItemToCrefoPayApiLogByIdSalesOrderItemAndRequestTypeAndResultCodes(
153
        int $idSalesOrderItem,
154
        string $apiLogRequestType,
155
        array $resultCodes
156
    ): ?PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer {
157
        $paymentCrefoPayOrderItemToCrefoPayApiLogEntity = $this->getPaymentCrefoPayOrderItemToCrefoPayApiLogQuery()
158
            ->useSpyPaymentCrefoPayOrderItemQuery()
159
                ->filterByFkSalesOrderItem($idSalesOrderItem)
160
            ->endUse()
161
            ->useSpyPaymentCrefoPayApiLogQuery()
162
                ->filterByRequestType($apiLogRequestType)
163
                ->filterByResultCode_In($resultCodes)
164
            ->endUse()
165
            ->findOne();
166
167
        if ($paymentCrefoPayOrderItemToCrefoPayApiLogEntity === null) {
168
            return null;
169
        }
170
171
        return $this->getMapper()
172
            ->mapEntityToPaymentCrefoPayOrderItemToCrefoPayApiLogTransfer(
173
                $paymentCrefoPayOrderItemToCrefoPayApiLogEntity,
174
                new PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer()
175
            );
176
    }
177
178
    /**
179
     * @param int $idSalesOrderItem
180
     * @param string $notificationTransactionStatus
181
     *
182
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer|null
183
     */
184
    public function findPaymentCrefoPayOrderItemToCrefoPayNotificationByIdSalesOrderItemAndTransactionStatus(
185
        int $idSalesOrderItem,
186
        string $notificationTransactionStatus
187
    ): ?PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer {
188
        $paymentCrefoPayOrderItemToCrefoPayNotificationEntity = $this->getPaymentCrefoPayOrderItemToCrefoPayNotificationQuery()
189
            ->useSpyPaymentCrefoPayOrderItemQuery()
190
                ->filterByFkSalesOrderItem($idSalesOrderItem)
191
            ->endUse()
192
            ->useSpyPaymentCrefoPayNotificationQuery()
193
                ->filterByTransactionStatus($notificationTransactionStatus)
194
            ->endUse()
195
            ->findOne();
196
197
        if ($paymentCrefoPayOrderItemToCrefoPayNotificationEntity === null) {
198
            return null;
199
        }
200
201
        return $this->getMapper()
202
            ->mapEntityToPaymentCrefoPayOrderItemToCrefoPayNotificationTransfer(
203
                $paymentCrefoPayOrderItemToCrefoPayNotificationEntity,
204
                new PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer()
205
            );
206
    }
207
208
    /**
209
     * @param int $idSalesOrderItem
210
     * @param string $notificationOrderStatus
211
     *
212
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer|null
213
     */
214
    public function findPaymentCrefoPayOrderItemToCrefoPayNotificationByIdSalesOrderItemAndOrderStatus(
215
        int $idSalesOrderItem,
216
        string $notificationOrderStatus
217
    ): ?PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer {
218
        $paymentCrefoPayOrderItemToCrefoPayNotificationEntity = $this->getPaymentCrefoPayOrderItemToCrefoPayNotificationQuery()
219
            ->useSpyPaymentCrefoPayOrderItemQuery()
220
                ->filterByFkSalesOrderItem($idSalesOrderItem)
221
            ->endUse()
222
            ->useSpyPaymentCrefoPayNotificationQuery()
223
                ->filterByOrderStatus($notificationOrderStatus)
224
            ->endUse()
225
            ->findOne();
226
227
        if ($paymentCrefoPayOrderItemToCrefoPayNotificationEntity === null) {
228
            return null;
229
        }
230
231
        return $this->getMapper()
232
            ->mapEntityToPaymentCrefoPayOrderItemToCrefoPayNotificationTransfer(
233
                $paymentCrefoPayOrderItemToCrefoPayNotificationEntity,
234
                new PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer()
235
            );
236
    }
237
238
    /**
239
     * @return \SprykerEco\Zed\CrefoPay\Persistence\Mapper\CrefoPayPersistenceMapper
240
     */
241
    protected function getMapper(): CrefoPayPersistenceMapper
242
    {
243
        return $this->getFactory()->createCrefoPayPersistenceMapper();
244
    }
245
246
    /**
247
     * @return \Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayQuery
248
     */
249
    protected function getPaymentCrefoPayQuery(): SpyPaymentCrefoPayQuery
250
    {
251
        return $this->getFactory()->createPaymentCrefoPayQuery();
252
    }
253
254
    /**
255
     * @return \Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayOrderItemQuery
256
     */
257
    protected function getPaymentCrefoPayOrderItemQuery(): SpyPaymentCrefoPayOrderItemQuery
258
    {
259
        return $this->getFactory()->createPaymentCrefoPayOrderItemQuery();
260
    }
261
262
    /**
263
     * @return \Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayOrderItemToCrefoPayApiLogQuery
264
     */
265
    protected function getPaymentCrefoPayOrderItemToCrefoPayApiLogQuery(): SpyPaymentCrefoPayOrderItemToCrefoPayApiLogQuery
266
    {
267
        return $this->getFactory()->createPaymentCrefoPayOrderItemToCrefoPayApiLogQuery();
268
    }
269
270
    /**
271
     * @return \Orm\Zed\CrefoPay\Persistence\SpyPaymentCrefoPayOrderItemToCrefoPayNotificationQuery
272
     */
273
    protected function getPaymentCrefoPayOrderItemToCrefoPayNotificationQuery(): SpyPaymentCrefoPayOrderItemToCrefoPayNotificationQuery
274
    {
275
        return $this->getFactory()->createPaymentCrefoPayOrderItemToCrefoPayNotificationQuery();
276
    }
277
}
278