getPaymentCrefoPayOrderItemToCrefoPayNotificationByIdSalesOrderItemAndTransactionStatus()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 10
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\CrefoPay\Business\Reader;
9
10
use Generated\Shared\Transfer\CrefoPayToSalesOrderItemsCollectionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ItemsCollectionTransfer 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\CrefoPayToSalesOrderItemTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...oSalesOrderItemTransfer 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\PaymentCrefoPayOrderItemCollectionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...rItemCollectionTransfer 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 Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...oCrefoPayApiLogTransfer 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 Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer;
0 ignored issues
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...
15
use Generated\Shared\Transfer\PaymentCrefoPayTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentCrefoPayTransfer 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...
16
use SprykerEco\Zed\CrefoPay\Persistence\CrefoPayRepositoryInterface;
17
18
class CrefoPayReader implements CrefoPayReaderInterface
19
{
20
    /**
21
     * @var array
22
     */
23
    protected const SUCCESS_RESULT_CODES = [0, 1];
24
25
    /**
26
     * @var \SprykerEco\Zed\CrefoPay\Persistence\CrefoPayRepositoryInterface
27
     */
28
    protected $repository;
29
30
    /**
31
     * @param \SprykerEco\Zed\CrefoPay\Persistence\CrefoPayRepositoryInterface $repository
32
     */
33
    public function __construct(CrefoPayRepositoryInterface $repository)
34
    {
35
        $this->repository = $repository;
36
    }
37
38
    /**
39
     * @param int $idSalesOrder
40
     *
41
     * @return \Generated\Shared\Transfer\PaymentCrefoPayTransfer
42
     */
43
    public function getPaymentCrefoPayByIdSalesOrder(int $idSalesOrder): PaymentCrefoPayTransfer
44
    {
45
        return $this->repository->findPaymentCrefoPayByIdSalesOrder($idSalesOrder) ?? new PaymentCrefoPayTransfer();
46
    }
47
48
    /**
49
     * @param string $crefoPayOrderId
50
     *
51
     * @return \Generated\Shared\Transfer\PaymentCrefoPayTransfer
52
     */
53
    public function getPaymentCrefoPayByCrefoPayOrderId(string $crefoPayOrderId): PaymentCrefoPayTransfer
54
    {
55
        return $this->repository->findPaymentCrefoPayByCrefoPayOrderId($crefoPayOrderId) ?? new PaymentCrefoPayTransfer();
56
    }
57
58
    /**
59
     * @param int $idSalesOrderItem
60
     *
61
     * @return \Generated\Shared\Transfer\PaymentCrefoPayTransfer
62
     */
63
    public function getPaymentCrefoPayByIdSalesOrderItem(int $idSalesOrderItem): PaymentCrefoPayTransfer
64
    {
65
        return $this->repository->findPaymentCrefoPayByIdSalesOrderItem($idSalesOrderItem) ?? new PaymentCrefoPayTransfer();
66
    }
67
68
    /**
69
     * @param string $crefoPayOrderId
70
     *
71
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemCollectionTransfer
72
     */
73
    public function getPaymentCrefoPayOrderItemCollectionByCrefoPayOrderId(string $crefoPayOrderId): PaymentCrefoPayOrderItemCollectionTransfer
74
    {
75
        return $this->repository->getPaymentCrefoPayOrderItemCollectionByCrefoPayOrderId($crefoPayOrderId);
76
    }
77
78
    /**
79
     * @param string $captureId
80
     *
81
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemCollectionTransfer
82
     */
83
    public function getPaymentCrefoPayOrderItemCollectionByCaptureId(string $captureId): PaymentCrefoPayOrderItemCollectionTransfer
84
    {
85
        return $this->repository->getPaymentCrefoPayOrderItemCollectionByCaptureId($captureId);
86
    }
87
88
    /**
89
     * @param \Generated\Shared\Transfer\CrefoPayToSalesOrderItemsCollectionTransfer $crefoPayToSalesOrderItemsCollection
90
     *
91
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemCollectionTransfer
92
     */
93
    public function getPaymentCrefoPayOrderItemCollectionByCrefoPayToSalesOrderItemsCollection(
94
        CrefoPayToSalesOrderItemsCollectionTransfer $crefoPayToSalesOrderItemsCollection
95
    ): PaymentCrefoPayOrderItemCollectionTransfer {
96
        $salesOrderItemIds = array_map(
97
            function (CrefoPayToSalesOrderItemTransfer $crefoPayToSalesOrderItemTransfer) {
98
                return $crefoPayToSalesOrderItemTransfer->getIdSalesOrderItem();
99
            },
100
            $crefoPayToSalesOrderItemsCollection->getCrefoPayToSalesOrderItems()->getArrayCopy(),
101
        );
102
103
        return $this->repository->getPaymentCrefoPayOrderItemCollectionBySalesOrderItemIds($salesOrderItemIds);
104
    }
105
106
    /**
107
     * @param array<int> $salesOrderItemIds
108
     *
109
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemCollectionTransfer
110
     */
111
    public function getPaymentCrefoPayOrderItemCollectionBySalesOrderItemIds(array $salesOrderItemIds): PaymentCrefoPayOrderItemCollectionTransfer
112
    {
113
        return $this->repository->getPaymentCrefoPayOrderItemCollectionBySalesOrderItemIds($salesOrderItemIds);
114
    }
115
116
    /**
117
     * @param int $idSalesOrderItem
118
     * @param string $apiLogRequestType
119
     *
120
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer
121
     */
122
    public function getPaymentCrefoPayOrderItemToCrefoPayApiLogByIdSalesOrderItemAndRequestTypeAndSuccessResult(
123
        int $idSalesOrderItem,
124
        string $apiLogRequestType
125
    ): PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer {
126
        return $this->repository
127
            ->findPaymentCrefoPayOrderItemToCrefoPayApiLogByIdSalesOrderItemAndRequestTypeAndResultCodes(
128
                $idSalesOrderItem,
129
                $apiLogRequestType,
130
                static::SUCCESS_RESULT_CODES,
131
            )
132
            ?? new PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer();
133
    }
134
135
    /**
136
     * @param int $idSalesOrderItem
137
     * @param string $notificationTransactionStatus
138
     *
139
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer
140
     */
141
    public function getPaymentCrefoPayOrderItemToCrefoPayNotificationByIdSalesOrderItemAndTransactionStatus(
142
        int $idSalesOrderItem,
143
        string $notificationTransactionStatus
144
    ): PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer {
145
        return $this->repository
146
            ->findPaymentCrefoPayOrderItemToCrefoPayNotificationByIdSalesOrderItemAndTransactionStatus(
147
                $idSalesOrderItem,
148
                $notificationTransactionStatus,
149
            )
150
            ?? new PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer();
151
    }
152
153
    /**
154
     * @param int $idSalesOrderItem
155
     * @param string $notificationOredrStatus
156
     *
157
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer
158
     */
159
    public function getPaymentCrefoPayOrderItemToCrefoPayNotificationByIdSalesOrderItemAndOrderStatus(
160
        int $idSalesOrderItem,
161
        string $notificationOredrStatus
162
    ): PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer {
163
        return $this->repository
164
            ->findPaymentCrefoPayOrderItemToCrefoPayNotificationByIdSalesOrderItemAndOrderStatus(
165
                $idSalesOrderItem,
166
                $notificationOredrStatus,
167
            )
168
            ?? new PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer();
169
    }
170
}
171