Passed
Pull Request — master (#9)
by Volodymyr
18:42 queued 13:43
created

findTransactionRequestLogByPaymentBraintreeId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 0
loc 13
rs 10
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
        $paymentBraintree = $this->getFactory()
32
            ->createPaymentBraintreeQuery()
33
            ->findOneByIdPaymentBraintree($idPaymentBraintree);
34
35
        if ($paymentBraintree === null) {
36
            return null;
37
        }
38
39
        return $this->getFactory()
40
            ->createBraintreePersistenceMapper()
41
            ->mapEntityToPaymentBraintreeTransfer($paymentBraintree, 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
        $paymentBraintree = $this->getFactory()
52
            ->createPaymentBraintreeQuery()
53
            ->findOneByFkSalesOrder($idSalesOrder);
54
55
        if ($paymentBraintree === null) {
56
            return null;
57
        }
58
59
        return $this->getFactory()
60
            ->createBraintreePersistenceMapper()
61
            ->mapEntityToPaymentBraintreeTransfer($paymentBraintree, 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
        $paymentBraintreeTransactionStatusLog = $this->getFactory()
72
            ->createPaymentBraintreeTransactionStatusLogQuery()
73
            ->findOneByFkPaymentBraintree($idPaymentBraintree);
74
75
        if ($paymentBraintreeTransactionStatusLog === null) {
76
            return null;
77
        }
78
79
        return $this->getFactory()
80
            ->createBraintreePersistenceMapper()
81
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLog, 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
        $paymentBraintreeTransactionStatusLog = $this->getFactory()
92
            ->createPaymentBraintreeTransactionStatusLogQuery()
93
            ->useSpyPaymentBraintreeQuery()
94
            ->filterByFkSalesOrder($idSalesOrder)
95
            ->endUse()
96
            ->findOne();
97
98
        if ($paymentBraintreeTransactionStatusLog === null) {
99
            return null;
100
        }
101
102
        return $this->getFactory()
103
            ->createBraintreePersistenceMapper()
104
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLog, new PaymentBraintreeTransactionStatusLogTransfer());
105
    }
106
107
    /**
108
     * @param int $idSalesOrder
109
     * @param string $transactionCode
110
     *
111
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionStatusLogTransfer
112
     */
113
    public function findPaymentBraintreeTransactionStatusLogQueryBySalesOrderIdAndTransactionCodeLatestFirst(
114
        int $idSalesOrder,
115
        string $transactionCode
116
    ): PaymentBraintreeTransactionStatusLogTransfer {
117
        $paymentBraintreeTransactionStatusLog = $this->getFactory()
118
            ->createPaymentBraintreeTransactionStatusLogQuery()
119
            ->useSpyPaymentBraintreeQuery()
120
            ->filterByFkSalesOrder($idSalesOrder)
121
            ->endUse()
122
            ->orderByIdPaymentBraintreeTransactionStatusLog(Criteria::DESC)
123
            ->withColumn(SpyPaymentBraintreeTransactionRequestLogTableMap::COL_TRANSACTION_CODE)
124
            ->addJoin(
125
                [
126
                    SpyPaymentBraintreeTransactionStatusLogTableMap::COL_TRANSACTION_ID,
127
                    SpyPaymentBraintreeTransactionRequestLogTableMap::COL_TRANSACTION_CODE,
128
                ],
129
                [
130
                    SpyPaymentBraintreeTransactionRequestLogTableMap::COL_TRANSACTION_ID,
131
                    Propel::getConnection()->quote($transactionCode),
132
                ]
133
            )
134
            ->findOne();
135
136
        if ($paymentBraintreeTransactionStatusLog === null) {
137
            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...
138
        }
139
140
        return $this->getFactory()
141
            ->createBraintreePersistenceMapper()
142
            ->mapEntityToPaymentBraintreeTransactionStatusLogTransfer($paymentBraintreeTransactionStatusLog, new PaymentBraintreeTransactionStatusLogTransfer());
143
    }
144
145
    /**
146
     * @param int $idPaymentBraintree
147
     *
148
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransactionRequestLogTransfer|null
149
     */
150
    public function findTransactionRequestLogByPaymentBraintreeId(int $idPaymentBraintree): ?PaymentBraintreeTransactionRequestLogTransfer
151
    {
152
        $paymentBraintreeTransactionRequestLog = $this->getFactory()
153
            ->createPaymentBraintreeTransactionRequestLogQuery()
154
            ->findOneByFkPaymentBraintree($idPaymentBraintree);
155
156
        if ($paymentBraintreeTransactionRequestLog === null) {
157
            return null;
158
        }
159
160
        return $this->getFactory()
161
            ->createBraintreePersistenceMapper()
162
            ->mapEntityToPaymentBraintreeTransactionRequestLogTransfer($paymentBraintreeTransactionRequestLog, new PaymentBraintreeTransactionRequestLogTransfer());
163
    }
164
}
165