Passed
Push — feature/paypal-express ( 8eac93...3cde97 )
by Volodymyr
05:19
created

BraintreeRepository::findPaymentBraintreeTransactionStatusLogQueryByOrderItem()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

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