Passed
Push — feature/eco-3135/eco-3149-dire... ( e79f9f...f6c32e )
by Volodymyr
05:30
created

findHeidelpayDirectDebitRegistrationByIdAndTransactionId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 17
rs 9.9332
cc 2
nc 2
nop 2
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 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...
12
use Spryker\Zed\Kernel\Persistence\AbstractRepository;
13
use Spryker\Zed\PropelOrm\Business\Runtime\ActiveQuery\Criteria;
14
use SprykerEco\Zed\Heidelpay\Persistence\Propel\Mapper\HeidelpayPersistenceMapper;
15
16
/**
17
 * @method \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayPersistenceFactory getFactory()
18
 */
19
class HeidelpayRepository extends AbstractRepository implements HeidelpayRepositoryInterface
20
{
21
    /**
22
     * @param string $registrationUniqueId
23
     *
24
     * @return \Generated\Shared\Transfer\HeidelpayDirectDebitRegistrationTransfer|null
25
     */
26
    public function findHeidelpayDirectDebitRegistrationByRegistrationUniqueId(
27
        string $registrationUniqueId
28
    ): ?HeidelpayDirectDebitRegistrationTransfer {
29
        $paymentHeidelpayDirectDebitRegistrationEntity = $this->getPaymentHeidelpayDirectDebitRegistrationQuery()
30
            ->filterByRegistrationUniqueId($registrationUniqueId)
31
            ->findOne();
32
33
        if ($paymentHeidelpayDirectDebitRegistrationEntity === null) {
34
            return null;
35
        }
36
37
        return $this->getMapper()
38
            ->mapEntityToHeidelpayDirectDebitRegistrationTransfer(
39
                $paymentHeidelpayDirectDebitRegistrationEntity,
40
                new HeidelpayDirectDebitRegistrationTransfer()
41
            );
42
    }
43
44
    /**
45
     * @param int $idCustomerAddress
46
     *
47
     * @return \Generated\Shared\Transfer\HeidelpayDirectDebitRegistrationTransfer|null
48
     */
49
    public function findLastHeidelpayDirectDebitRegistrationByIdCustomerAddress(
50
        int $idCustomerAddress
51
    ): ?HeidelpayDirectDebitRegistrationTransfer {
52
        $paymentHeidelpayDirectDebitRegistrationEntity = $this->getPaymentHeidelpayDirectDebitRegistrationQuery()
53
            ->filterByFkCustomerAddress($idCustomerAddress)
54
            ->orderByIdDirectDebitRegistration(Criteria::DESC)
55
            ->findOne();
56
57
        if ($paymentHeidelpayDirectDebitRegistrationEntity === null) {
58
            return null;
59
        }
60
61
        return $this->getMapper()
62
            ->mapEntityToHeidelpayDirectDebitRegistrationTransfer(
63
                $paymentHeidelpayDirectDebitRegistrationEntity,
64
                new HeidelpayDirectDebitRegistrationTransfer()
65
            );
66
    }
67
68
    /**
69
     * @param int $idRegistration
70
     * @param string $transactionId
71
     *
72
     * @return \Generated\Shared\Transfer\HeidelpayDirectDebitRegistrationTransfer|null
73
     */
74
    public function findHeidelpayDirectDebitRegistrationByIdAndTransactionId(
75
        int $idRegistration,
76
        string $transactionId
77
    ): ?HeidelpayDirectDebitRegistrationTransfer {
78
        $paymentHeidelpayDirectDebitRegistrationEntity = $this->getPaymentHeidelpayDirectDebitRegistrationQuery()
79
            ->filterByIdDirectDebitRegistration($idRegistration)
80
            ->filterByTransactionId($transactionId)
81
            ->findOne();
82
83
        if ($paymentHeidelpayDirectDebitRegistrationEntity === null) {
84
            return null;
85
        }
86
87
        return $this->getMapper()
88
            ->mapEntityToHeidelpayDirectDebitRegistrationTransfer(
89
                $paymentHeidelpayDirectDebitRegistrationEntity,
90
                new HeidelpayDirectDebitRegistrationTransfer()
91
            );
92
    }
93
94
    /**
95
     * @return \SprykerEco\Zed\Heidelpay\Persistence\Propel\Mapper\HeidelpayPersistenceMapper
96
     */
97
    protected function getMapper(): HeidelpayPersistenceMapper
98
    {
99
        return $this->getFactory()->createHeidelpayPersistenceMapper();
100
    }
101
102
    /**
103
     * @return \Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayDirectDebitRegistrationQuery
104
     */
105
    protected function getPaymentHeidelpayDirectDebitRegistrationQuery(): SpyPaymentHeidelpayDirectDebitRegistrationQuery
106
    {
107
        return $this->getFactory()->createPaymentHeidelpayDirectDebitRegistrationQuery();
108
    }
109
}
110