Passed
Push — feature/eco-3135/eco-3149-dire... ( b1393a...0436c5 )
by Aleksey
05:03
created

getPaymentHeidelpayTransactionLogQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 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\Heidelpay\Persistence;
9
10
use Generated\Shared\Transfer\HeidelpayDirectDebitRegistrationTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...bitRegistrationTransfer 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\HeidelpayTransactionLogTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...yTransactionLogTransfer 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 Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayDirectDebitRegistrationQuery;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Heidelpay\Persis...tDebitRegistrationQuery 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\Heidelpay\Persistence\SpyPaymentHeidelpayTransactionLogQuery;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Heidelpay\Persis...lpayTransactionLogQuery 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 Spryker\Zed\Kernel\Persistence\AbstractRepository;
15
use Spryker\Zed\PropelOrm\Business\Runtime\ActiveQuery\Criteria;
16
use SprykerEco\Zed\Heidelpay\Persistence\Propel\Mapper\HeidelpayPersistenceMapper;
17
18
/**
19
 * @method \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayPersistenceFactory getFactory()
20
 */
21
class HeidelpayRepository extends AbstractRepository implements HeidelpayRepositoryInterface
22
{
23
    /**
24
     * @param string $registrationUniqueId
25
     *
26
     * @return \Generated\Shared\Transfer\HeidelpayDirectDebitRegistrationTransfer|null
27
     */
28
    public function findHeidelpayDirectDebitRegistrationByRegistrationUniqueId(
29
        string $registrationUniqueId
30
    ): ?HeidelpayDirectDebitRegistrationTransfer {
31
        $paymentHeidelpayDirectDebitRegistrationEntity = $this->getPaymentHeidelpayDirectDebitRegistrationQuery()
32
            ->filterByRegistrationUniqueId($registrationUniqueId)
33
            ->findOne();
34
35
        if ($paymentHeidelpayDirectDebitRegistrationEntity === null) {
36
            return null;
37
        }
38
39
        return $this->getMapper()
40
            ->mapEntityToHeidelpayDirectDebitRegistrationTransfer(
41
                $paymentHeidelpayDirectDebitRegistrationEntity,
42
                new HeidelpayDirectDebitRegistrationTransfer()
43
            );
44
    }
45
46
    /**
47
     * @param int $idCustomerAddress
48
     *
49
     * @return \Generated\Shared\Transfer\HeidelpayDirectDebitRegistrationTransfer|null
50
     */
51
    public function findLastHeidelpayDirectDebitRegistrationByIdCustomerAddress(
52
        int $idCustomerAddress
53
    ): ?HeidelpayDirectDebitRegistrationTransfer {
54
        $paymentHeidelpayDirectDebitRegistrationEntity = $this->getPaymentHeidelpayDirectDebitRegistrationQuery()
55
            ->filterByFkCustomerAddress($idCustomerAddress)
56
            ->orderByIdDirectDebitRegistration(Criteria::DESC)
57
            ->findOne();
58
59
        if ($paymentHeidelpayDirectDebitRegistrationEntity === null) {
60
            return null;
61
        }
62
63
        return $this->getMapper()
64
            ->mapEntityToHeidelpayDirectDebitRegistrationTransfer(
65
                $paymentHeidelpayDirectDebitRegistrationEntity,
66
                new HeidelpayDirectDebitRegistrationTransfer()
67
            );
68
    }
69
70
    /**
71
     * @param int $idRegistration
72
     * @param string $transactionId
73
     *
74
     * @return \Generated\Shared\Transfer\HeidelpayDirectDebitRegistrationTransfer|null
75
     */
76
    public function findHeidelpayDirectDebitRegistrationByIdAndTransactionId(
77
        int $idRegistration,
78
        string $transactionId
79
    ): ?HeidelpayDirectDebitRegistrationTransfer {
80
        $paymentHeidelpayDirectDebitRegistrationEntity = $this->getPaymentHeidelpayDirectDebitRegistrationQuery()
81
            ->filterByIdDirectDebitRegistration($idRegistration)
82
            ->filterByTransactionId($transactionId)
83
            ->findOne();
84
85
        if ($paymentHeidelpayDirectDebitRegistrationEntity === null) {
86
            return null;
87
        }
88
89
        return $this->getMapper()
90
            ->mapEntityToHeidelpayDirectDebitRegistrationTransfer(
91
                $paymentHeidelpayDirectDebitRegistrationEntity,
92
                new HeidelpayDirectDebitRegistrationTransfer()
93
            );
94
    }
95
96
    /**
97
     * @param int $idSalesOrder
98
     * @param string $transactionType
99
     *
100
     * @return \Generated\Shared\Transfer\HeidelpayTransactionLogTransfer|null
101
     */
102
    public function findHeidelpayTransactionLogByIdSalesOrderAndTransactionType(
103
        int $idSalesOrder,
104
        string $transactionType
105
    ): ?HeidelpayTransactionLogTransfer {
106
        $paymentHeidelpayTransactionLog = $this->getPaymentHeidelpayTransactionLogQuery()
107
            ->filterByFkSalesOrder($idSalesOrder)
108
            ->filterByTransactionType($transactionType)
109
            ->findOne();
110
111
        if ($paymentHeidelpayTransactionLog === null) {
112
            return null;
113
        }
114
115
        return $this->getMapper()
116
            ->mapEntityToHeidelpayTransactionLogTransfer(
117
                $paymentHeidelpayTransactionLog,
118
                new HeidelpayTransactionLogTransfer()
119
            );
120
    }
121
122
    /**
123
     * @return \SprykerEco\Zed\Heidelpay\Persistence\Propel\Mapper\HeidelpayPersistenceMapper
124
     */
125
    protected function getMapper(): HeidelpayPersistenceMapper
126
    {
127
        return $this->getFactory()->createHeidelpayPersistenceMapper();
128
    }
129
130
    /**
131
     * @return \Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayDirectDebitRegistrationQuery
132
     */
133
    protected function getPaymentHeidelpayDirectDebitRegistrationQuery(): SpyPaymentHeidelpayDirectDebitRegistrationQuery
134
    {
135
        return $this->getFactory()->createPaymentHeidelpayDirectDebitRegistrationQuery();
136
    }
137
138
    /**
139
     * @return \Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayTransactionLogQuery
140
     */
141
    protected function getPaymentHeidelpayTransactionLogQuery(): SpyPaymentHeidelpayTransactionLogQuery
142
    {
143
        return $this->getFactory()->createPaymentHeidelpayTransactionLogQuery();
144
    }
145
}
146