Completed
Push — master ( 2a18cf...56a686 )
by Oleksandr
14s queued 11s
created

HeidelpayRepository   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
eloc 30
c 1
b 0
f 1
dl 0
loc 90
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A findPaymentHeidelpayNotificationByUniqueId() 0 14 2
A getPaymentHeidelpayQuery() 0 3 1
A getPaymentHeidelpayNotificationCollectionByTransactionIdAndPaymentCode() 0 13 1
A getPaymentHeidelpayNotificationQuery() 0 3 1
A findHeidelpayPaymentByIdSalesOrder() 0 14 2
A getMapper() 0 3 1
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\HeidelpayNotificationCollectionTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...ationCollectionTransfer 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\HeidelpayNotificationTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...payNotificationTransfer 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\HeidelpayPaymentTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\HeidelpayPaymentTransfer 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\SpyPaymentHeidelpayNotificationQuery;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Heidelpay\Persis...delpayNotificationQuery 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\Heidelpay\Persistence\SpyPaymentHeidelpayQuery;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Heidelpay\Persis...pyPaymentHeidelpayQuery 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 Spryker\Zed\Kernel\Persistence\AbstractRepository;
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 int $idSalesOrder
25
     *
26
     * @return \Generated\Shared\Transfer\HeidelpayPaymentTransfer|null
27
     */
28
    public function findHeidelpayPaymentByIdSalesOrder(int $idSalesOrder): ?HeidelpayPaymentTransfer
29
    {
30
        $paymentHeidelpayEntity = $this->getPaymentHeidelpayQuery()
31
            ->filterByFkSalesOrder($idSalesOrder)
32
            ->findOne();
33
34
        if ($paymentHeidelpayEntity === null) {
35
            return null;
36
        }
37
38
        return $this->getMapper()
39
            ->mapEntityToHeidelpayPaymentTransfer(
40
                $paymentHeidelpayEntity,
41
                new HeidelpayPaymentTransfer()
42
            );
43
    }
44
45
    /**
46
     * @param string $uniqueId
47
     *
48
     * @return \Generated\Shared\Transfer\HeidelpayNotificationTransfer|null
49
     */
50
    public function findPaymentHeidelpayNotificationByUniqueId(string $uniqueId): ?HeidelpayNotificationTransfer
51
    {
52
        $paymentHeidelpayNotification = $this->getPaymentHeidelpayNotificationQuery()
53
            ->filterByUniqueId($uniqueId)
54
            ->findOne();
55
56
        if ($paymentHeidelpayNotification === null) {
57
            return null;
58
        }
59
60
        return $this->getMapper()
61
            ->mapEntityToHeidelpayNotificationTransfer(
62
                $paymentHeidelpayNotification,
63
                new HeidelpayNotificationTransfer()
64
            );
65
    }
66
67
    /**
68
     * @param string $transactionId
69
     * @param string $paymentCode
70
     *
71
     * @return \Generated\Shared\Transfer\HeidelpayNotificationCollectionTransfer
72
     */
73
    public function getPaymentHeidelpayNotificationCollectionByTransactionIdAndPaymentCode(
74
        string $transactionId,
75
        string $paymentCode
76
    ): HeidelpayNotificationCollectionTransfer {
77
        $paymentHeidelpayNotification = $this->getPaymentHeidelpayNotificationQuery()
78
            ->filterByTransactionId($transactionId)
79
            ->filterByPaymentCode($paymentCode)
80
            ->find();
81
82
        return $this->getMapper()
83
            ->mapNotificationEntitiesToHeidelpayNotificationCollection(
84
                $paymentHeidelpayNotification,
85
                new HeidelpayNotificationCollectionTransfer()
86
            );
87
    }
88
89
    /**
90
     * @return \SprykerEco\Zed\Heidelpay\Persistence\Propel\Mapper\HeidelpayPersistenceMapper
91
     */
92
    protected function getMapper(): HeidelpayPersistenceMapper
93
    {
94
        return $this->getFactory()->createHeidelpayPersistenceMapper();
95
    }
96
97
    /**
98
     * @return \Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayQuery
99
     */
100
    protected function getPaymentHeidelpayQuery(): SpyPaymentHeidelpayQuery
101
    {
102
        return $this->getFactory()->createPaymentHeidelpayQuery();
103
    }
104
105
    /**
106
     * @return \Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayNotificationQuery
107
     */
108
    protected function getPaymentHeidelpayNotificationQuery(): SpyPaymentHeidelpayNotificationQuery
109
    {
110
        return $this->getFactory()->createPaymentHeidelpayNotificationQuery();
111
    }
112
}
113