Passed
Push — feature/eco-2295/master ( c16d9a...3e2e74 )
by Aleksey
03:06
created

getPaymentCrefoPayOrderItemCollectionBySalesOrderItemIds()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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