Passed
Push — feature/paypal-express ( aa383f...32ec15 )
by Volodymyr
05:03
created

findPaymentBraintreeTransactionStatusLogQueryBySalesOrderId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 1
dl 0
loc 16
rs 9.9
c 0
b 0
f 0
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\Braintree\Persistence;
9
10
use Generated\Shared\Transfer\PaymentBraintreeTransactionRequestLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ctionRequestLogTransfer 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\PaymentBraintreeTransactionStatusLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...actionStatusLogTransfer 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\PaymentBraintreeTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentBraintreeTransfer 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 Orm\Zed\Braintree\Persistence\Map\SpyPaymentBraintreeTransactionRequestLogTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Braintree\Persis...ctionRequestLogTableMap 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\Braintree\Persistence\Map\SpyPaymentBraintreeTransactionStatusLogTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Braintree\Persis...actionStatusLogTableMap 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 Propel\Runtime\ActiveQuery\Criteria;
16
use Propel\Runtime\Propel;
17
use Spryker\Zed\Kernel\Persistence\AbstractRepository;
18
19
/**
20
 * @method \SprykerEco\Zed\Braintree\Persistence\BraintreePersistenceFactory getFactory()
21
 */
22
class BraintreeRepository extends AbstractRepository implements BraintreeRepositoryInterface
23
{
24
    /**
25
     * @param int $idPaymentBraintree
26
     *
27
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransfer|null
28
     */
29
    public function findPaymentBraintreeById(int $idPaymentBraintree): ?PaymentBraintreeTransfer
30
    {
31
        $paymentBraintreeEntity = $this->getFactory()
32
            ->createPaymentBraintreeQuery()
33
            ->findOneByIdPaymentBraintree($idPaymentBraintree);
34
35
        if ($paymentBraintreeEntity === null) {
36
            return null;
37
        }
38
39
        return $this->getFactory()
40
            ->createBraintreePersistenceMapper()
41
            ->mapEntityToPaymentBraintreeTransfer($paymentBraintreeEntity, new PaymentBraintreeTransfer());
42
    }
43
44
    /**
45
     * @param int $idSalesOrder
46
     *
47
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransfer|null
48
     */
49
    public function findPaymentBraintreeBySalesOrderId(int $idSalesOrder): ?PaymentBraintreeTransfer
50
    {
51
        $paymentBraintreeEntity = $this->getFactory()
52
            ->createPaymentBraintreeQuery()
53
            ->findOneByFkSalesOrder($idSalesOrder);
54
55
        if ($paymentBraintreeEntity === null) {
56
            return null;
57
        }
58
59
        return $this->getFactory()
60
            ->createBraintreePersistenceMapper()
61
            ->mapEntityToPaymentBraintreeTransfer($paymentBraintreeEntity, new PaymentBraintreeTransfer());
62
    }
63
64
    /**
65
     * @param int $idPaymentBraintree
66
     *
67
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer|null
68
     */
69
    public function findPaymentBraintreeTransactionStatusLogQueryByPaymentBraintreeId(int $idPaymentBraintree): ?PaymentBraintreeTransactionStatusLogTransfer
70
    {
71
        $paymentBraintreeTransactionStatusLogEntity = $this->getFactory()
72
            ->createPaymentBraintreeTransactionStatusLogQuery()
73
            ->findOneByFkPaymentBraintree($idPaymentBraintree);
74
75
        if ($paymentBraintreeTransactionStatusLogEntity === null) {
76
            return null;
77
        }
78
79
        return $this->getFactory()
80
            ->createBraintreePersistenceMapper()
81
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
82
    }
83
84
    /**
85
     * @param int $idSalesOrder
86
     *
87
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer|null
88
     */
89
    public function findPaymentBraintreeTransactionStatusLogQueryBySalesOrderId(int $idSalesOrder): ?PaymentBraintreeTransactionStatusLogTransfer
90
    {
91
        $paymentBraintreeTransactionStatusLogEntity = $this->getFactory()
92
            ->createPaymentBraintreeTransactionStatusLogQuery()
93
            ->useSpyPaymentBraintreeQuery()
94
            ->filterByFkSalesOrder($idSalesOrder)
95
            ->endUse()
96
            ->findOne();
97
98
        if ($paymentBraintreeTransactionStatusLogEntity === null) {
99
            return null;
100
        }
101
102
        return $this->getFactory()
103
            ->createBraintreePersistenceMapper()
104
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
105
    }
106
107
    /**
108
     * @param int $idSalesOrder
109
     * @param string $transactionCode
110
     * @param string|array $statusCode
111
     *
112
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer|null
113
     */
114
    public function findPaymentBraintreeTransactionStatusLogQueryBySalesOrderIdAndTransactionCodeLatestFirst(
115
        int $idSalesOrder,
116
        string $transactionCode,
117
        $statusCode
118
    ): ?PaymentBraintreeTransactionStatusLogTransfer {
119
        $paymentBraintreeTransactionStatusLogEntity = $this->getFactory()
120
            ->createPaymentBraintreeTransactionStatusLogQuery()
121
            ->useSpyPaymentBraintreeQuery()
122
            ->filterByFkSalesOrder($idSalesOrder)
123
            ->endUse()
124
            ->orderByIdPaymentBraintreeTransactionStatusLog(Criteria::DESC)
125
            ->withColumn(SpyPaymentBraintreeTransactionRequestLogTableMap::COL_TRANSACTION_CODE)
126
            ->addJoin(
127
                [
128
                    SpyPaymentBraintreeTransactionStatusLogTableMap::COL_TRANSACTION_ID,
129
                    SpyPaymentBraintreeTransactionRequestLogTableMap::COL_TRANSACTION_CODE,
130
                ],
131
                [
132
                    SpyPaymentBraintreeTransactionRequestLogTableMap::COL_TRANSACTION_ID,
133
                    Propel::getConnection()->quote($transactionCode),
134
                ]
135
            )
136
            ->filterByTransactionStatus((array)$statusCode, Criteria::IN)
137
            ->findOne();
138
139
        if ($paymentBraintreeTransactionStatusLogEntity === null) {
140
            return null;
141
        }
142
143
        return $this->getFactory()
144
            ->createBraintreePersistenceMapper()
145
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
146
    }
147
148
    /**
149
     * @param int $idSalesOrder
150
     * @param string $transactionCode
151
     * @param string|array $statusCode
152
     *
153
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer|null
154
     */
155
    public function findSucceededPaymentBraintreeTransactionStatusLogQueryBySalesOrderIdAndTransactionCode(
156
        int $idSalesOrder,
157
        string $transactionCode,
158
        $statusCode
159
    ): ?PaymentBraintreeTransactionStatusLogTransfer {
160
        $paymentBraintreeTransactionStatusLogEntity = $this->getFactory()
161
            ->createPaymentBraintreeTransactionStatusLogQuery()
162
            ->filterByTransactionCode($transactionCode)
163
            ->filterByTransactionStatus((array)$statusCode, Criteria::IN)
164
            ->filterByIsShipmentOperation(false)
165
            ->useSpyPaymentBraintreeQuery()
166
                ->filterByFkSalesOrder($idSalesOrder)
167
            ->endUse()
168
            ->filterByIsSuccess(true)
169
            ->findOne();
170
171
        if ($paymentBraintreeTransactionStatusLogEntity === null) {
172
            return null;
173
        }
174
175
        return $this->getFactory()
176
            ->createBraintreePersistenceMapper()
177
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
178
    }
179
180
    /**
181
     * @param int $idSalesOrderItem
182
     *
183
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer|null
184
     */
185
    public function findPaymentBraintreeTransactionStatusLogQueryByOrderItem(
186
        int $idSalesOrderItem
187
    ): ?PaymentBraintreeTransactionStatusLogTransfer {
188
        $paymentBraintreeTransactionStatusLogEntity = $this->getFactory()
189
            ->createPaymentBraintreeTransactionStatusLogQuery()
190
            ->useSpyPaymentBraintreeOrderItemQuery()
191
                ->filterByFkSalesOrderItem($idSalesOrderItem)
192
            ->endUse()
193
            ->findOne();
194
195
        if ($paymentBraintreeTransactionStatusLogEntity === null) {
196
            return null;
197
        }
198
199
        return $this->getFactory()
200
            ->createBraintreePersistenceMapper()
201
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
202
    }
203
204
    /**
205
     * @param int $idPaymentBraintree
206
     *
207
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionRequestLogTransfer|null
208
     */
209
    public function findTransactionRequestLogByPaymentBraintreeId(int $idPaymentBraintree): ?PaymentBraintreeTransactionRequestLogTransfer
210
    {
211
        $paymentBraintreeTransactionRequestLogEntity = $this->getFactory()
212
            ->createPaymentBraintreeTransactionRequestLogQuery()
213
            ->findOneByFkPaymentBraintree($idPaymentBraintree);
214
215
        if ($paymentBraintreeTransactionRequestLogEntity === null) {
216
            return null;
217
        }
218
219
        return $this->getFactory()
220
            ->createBraintreePersistenceMapper()
221
            ->mapEntityToPaymentBraintreeTransactionRequestLogTransfer($paymentBraintreeTransactionRequestLogEntity, new PaymentBraintreeTransactionRequestLogTransfer());
222
    }
223
224
    /**
225
     * @param int $idSalesOrder
226
     *
227
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer|null
228
     */
229
    public function findTransactionRequestLogByIdSalesOrderForShipment(int $idSalesOrder): ?PaymentBraintreeTransactionStatusLogTransfer
230
    {
231
        $paymentBraintreeTransactionStatusLogEntity = $this->getFactory()
232
            ->createPaymentBraintreeTransactionStatusLogQuery()
233
            ->useSpyPaymentBraintreeQuery()
234
                ->filterByFkSalesOrder($idSalesOrder)
235
            ->endUse()
236
            ->filterByIsShipmentOperation(true)
237
            ->findOne();
238
239
        if ($paymentBraintreeTransactionStatusLogEntity === null) {
240
            return null;
241
        }
242
243
        return $this->getFactory()
244
            ->createBraintreePersistenceMapper()
245
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
246
    }
247
}
248