Passed
Pull Request — master (#13)
by Oleksandr
20:56 queued 15:27
created

findTransactionRequestLogByIdSalesOrderForShipment()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 1
dl 0
loc 17
rs 9.8666
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\PaymentBraintreeOrderItemTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...intreeOrderItemTransfer 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 Propel\Runtime\ActiveQuery\Criteria;
14
use Spryker\Zed\Kernel\Persistence\AbstractRepository;
15
16
/**
17
 * @method \SprykerEco\Zed\Braintree\Persistence\BraintreePersistenceFactory getFactory()
18
 */
19
class BraintreeRepository extends AbstractRepository implements BraintreeRepositoryInterface
20
{
21
    /**
22
     * @param int $idPaymentBraintree
23
     *
24
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransfer|null
25
     */
26
    public function findPaymentBraintreeById(int $idPaymentBraintree): ?PaymentBraintreeTransfer
27
    {
28
        $paymentBraintreeEntity = $this->getFactory()
29
            ->createPaymentBraintreeQuery()
30
            ->findOneByIdPaymentBraintree($idPaymentBraintree);
31
32
        if ($paymentBraintreeEntity === null) {
33
            return null;
34
        }
35
36
        return $this->getFactory()
37
            ->createBraintreePersistenceMapper()
38
            ->mapEntityToPaymentBraintreeTransfer($paymentBraintreeEntity, new PaymentBraintreeTransfer());
39
    }
40
41
    /**
42
     * @param int $idSalesOrder
43
     *
44
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransfer|null
45
     */
46
    public function findPaymentBraintreeBySalesOrderId(int $idSalesOrder): ?PaymentBraintreeTransfer
47
    {
48
        $paymentBraintreeEntity = $this->getFactory()
49
            ->createPaymentBraintreeQuery()
50
            ->findOneByFkSalesOrder($idSalesOrder);
51
52
        if ($paymentBraintreeEntity === null) {
53
            return null;
54
        }
55
56
        return $this->getFactory()
57
            ->createBraintreePersistenceMapper()
58
            ->mapEntityToPaymentBraintreeTransfer($paymentBraintreeEntity, new PaymentBraintreeTransfer());
59
    }
60
61
    /**
62
     * @param int $idSalesOrderItem
63
     *
64
     * @return \Generated\Shared\Transfer\PaymentBraintreeOrderItemTransfer|null
65
     */
66
    public function findPaymentBraintreeOrderItemByIdSalesOrderItem(int $idSalesOrderItem): ?PaymentBraintreeOrderItemTransfer
67
    {
68
        $paymentBraintreeOrderItemEntity = $this->getFactory()
69
            ->createPaymentBraintreeOrderItemQuery()
70
            ->findOneByFkSalesOrderItem($idSalesOrderItem);
71
72
        if ($paymentBraintreeOrderItemEntity === null) {
73
            return null;
74
        }
75
76
        return $this->getFactory()
77
            ->createBraintreePersistenceMapper()
78
            ->mapEntityToPaymentBraintreeOrderItemTransfer($paymentBraintreeOrderItemEntity, new PaymentBraintreeOrderItemTransfer());
79
    }
80
81
    /**
82
     * @param int $idSalesOrder
83
     *
84
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer|null
85
     */
86
    public function findPaymentBraintreeTransactionStatusLogQueryBySalesOrderId(int $idSalesOrder): ?PaymentBraintreeTransactionStatusLogTransfer
87
    {
88
        $paymentBraintreeTransactionStatusLogEntity = $this->getFactory()
89
            ->createPaymentBraintreeTransactionStatusLogQuery()
90
            ->useSpyPaymentBraintreeQuery()
91
            ->filterByFkSalesOrder($idSalesOrder)
92
            ->endUse()
93
            ->findOne();
94
95
        if ($paymentBraintreeTransactionStatusLogEntity === null) {
96
            return null;
97
        }
98
99
        return $this->getFactory()
100
            ->createBraintreePersistenceMapper()
101
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
102
    }
103
104
    /**
105
     * @param int $idSalesOrder
106
     * @param string $transactionCode
107
     * @param string|array $statusCode
108
     *
109
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer|null
110
     */
111
    public function findSucceededPaymentBraintreeTransactionStatusLogQueryBySalesOrderIdAndTransactionCode(
112
        int $idSalesOrder,
113
        string $transactionCode,
114
        $statusCode
115
    ): ?PaymentBraintreeTransactionStatusLogTransfer {
116
        $paymentBraintreeTransactionStatusLogEntity = $this->getFactory()
117
            ->createPaymentBraintreeTransactionStatusLogQuery()
118
            ->filterByTransactionCode($transactionCode)
119
            ->filterByTransactionStatus((array)$statusCode, Criteria::IN)
120
            ->filterByIsShipmentOperation(false)
121
            ->useSpyPaymentBraintreeQuery()
122
                ->filterByFkSalesOrder($idSalesOrder)
123
            ->endUse()
124
            ->filterByIsSuccess(true)
125
            ->findOne();
126
127
        if ($paymentBraintreeTransactionStatusLogEntity === null) {
128
            return null;
129
        }
130
131
        return $this->getFactory()
132
            ->createBraintreePersistenceMapper()
133
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
134
    }
135
136
    /**
137
     * @param int $idPaymentBraintreeOrderItem
138
     *
139
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer|null
140
     */
141
    public function findPaymentBraintreeTransactionStatusLogQueryByPaymentBraintreeOrderItem(
142
        int $idPaymentBraintreeOrderItem
143
    ): ?PaymentBraintreeTransactionStatusLogTransfer {
144
        $paymentBraintreeTransactionStatusLogEntity = $this->getFactory()
145
            ->createPaymentBraintreeTransactionStatusLogQuery()
146
            ->useSpyPaymentBraintreeTransactionOrderItemQuery()
147
                ->filterByFkPaymentBraintreeOrderItem($idPaymentBraintreeOrderItem)
148
            ->endUse()
149
            ->findOne();
150
151
        if ($paymentBraintreeTransactionStatusLogEntity === null) {
152
            return null;
153
        }
154
155
        return $this->getFactory()
156
            ->createBraintreePersistenceMapper()
157
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
158
    }
159
160
    /**
161
     * @param int $idSalesOrder
162
     *
163
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer|null
164
     */
165
    public function findTransactionRequestLogByIdSalesOrderForShipment(int $idSalesOrder): ?PaymentBraintreeTransactionStatusLogTransfer
166
    {
167
        $paymentBraintreeTransactionStatusLogEntity = $this->getFactory()
168
            ->createPaymentBraintreeTransactionStatusLogQuery()
169
            ->useSpyPaymentBraintreeQuery()
170
                ->filterByFkSalesOrder($idSalesOrder)
171
            ->endUse()
172
            ->filterByIsShipmentOperation(true)
173
            ->findOne();
174
175
        if ($paymentBraintreeTransactionStatusLogEntity === null) {
176
            return null;
177
        }
178
179
        return $this->getFactory()
180
            ->createBraintreePersistenceMapper()
181
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
182
    }
183
}
184