Completed
Push — feature/paypal-express ( 45c1ed...8563e1 )
by Oleksandr
22:44 queued 22:43
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
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;
0 ignored issues
show
Bug Best Practice introduced by
The expression return null returns the type null which is incompatible with the type-hinted return Generated\Shared\Transfe...actionStatusLogTransfer.
Loading history...
141
        }
142
143
        return $this->getFactory()
144
            ->createBraintreePersistenceMapper()
145
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLogEntity, new PaymentBraintreeTransactionStatusLogTransfer());
146
    }
147
148
    /**
149
     * @param int $idPaymentBraintree
150
     *
151
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionRequestLogTransfer|null
152
     */
153
    public function findTransactionRequestLogByPaymentBraintreeId(int $idPaymentBraintree): ?PaymentBraintreeTransactionRequestLogTransfer
154
    {
155
        $paymentBraintreeTransactionRequestLogEntity = $this->getFactory()
156
            ->createPaymentBraintreeTransactionRequestLogQuery()
157
            ->findOneByFkPaymentBraintree($idPaymentBraintree);
158
159
        if ($paymentBraintreeTransactionRequestLogEntity === null) {
160
            return null;
161
        }
162
163
        return $this->getFactory()
164
            ->createBraintreePersistenceMapper()
165
            ->mapEntityToPaymentBraintreeTransactionRequestLogTransfer($paymentBraintreeTransactionRequestLogEntity, new PaymentBraintreeTransactionRequestLogTransfer());
166
    }
167
}
168