Passed
Push — feature/eco-574/eco-2266-check... ( efd21d )
by Aleksey
08:13
created

PaymentReader::getPaymentByIdSalesOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
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\Afterpay\Business\Payment;
9
10
use Generated\Shared\Transfer\AfterpayPaymentOrderItemTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...aymentOrderItemTransfer 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\AfterpayPaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\AfterpayPaymentTransfer 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\Afterpay\Persistence\SpyPaymentAfterpay;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Afterpay\Persistence\SpyPaymentAfterpay 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\Afterpay\Persistence\SpyPaymentAfterpayOrderItem;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Afterpay\Persist...aymentAfterpayOrderItem 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 SprykerEco\Zed\Afterpay\Persistence\AfterpayQueryContainerInterface;
15
16
class PaymentReader implements PaymentReaderInterface
17
{
18
    /**
19
     * @var \SprykerEco\Zed\Afterpay\Persistence\AfterpayQueryContainerInterface
20
     */
21
    protected $afterpayQueryContainer;
22
23
    /**
24
     * @param \SprykerEco\Zed\Afterpay\Persistence\AfterpayQueryContainerInterface $afterpayQueryContainer
25
     */
26
    public function __construct(AfterpayQueryContainerInterface $afterpayQueryContainer)
27
    {
28
        $this->afterpayQueryContainer = $afterpayQueryContainer;
29
    }
30
31
    /**
32
     * @param int $idSalesOrder
33
     *
34
     * @return \Generated\Shared\Transfer\AfterpayPaymentTransfer
35
     */
36
    public function getPaymentByIdSalesOrder(int $idSalesOrder): AfterpayPaymentTransfer
37
    {
38
        $afterpayPaymentEntity = $this->getPaymentEntityByIdSalesOrder($idSalesOrder);
39
40
        $paymentTransfer = new AfterpayPaymentTransfer();
41
        $paymentTransfer->fromArray($afterpayPaymentEntity->toArray(), true);
42
43
        return $paymentTransfer;
44
    }
45
46
    /**
47
     * @param int $idSalesOrderItem
48
     * @param int $idPayment
49
     *
50
     * @return \Generated\Shared\Transfer\AfterpayPaymentOrderItemTransfer
51
     */
52
    public function getPaymentOrderItemByIdSalesOrderItemAndIdPayment(int $idSalesOrderItem, int $idPayment): AfterpayPaymentOrderItemTransfer
53
    {
54
        $afterpayPaymentOrderItemEntity = $this->getPaymentOrderItemEntityByIdSalesOrderItemAndIdPayment(
55
            $idSalesOrderItem,
56
            $idPayment
57
        );
58
59
        $paymentOrderItemTransfer = new AfterpayPaymentOrderItemTransfer();
60
        $paymentOrderItemTransfer->fromArray($afterpayPaymentOrderItemEntity->toArray(), true);
61
62
        return $paymentOrderItemTransfer;
63
    }
64
65
    /**
66
     * @param int $idSalesOrder
67
     *
68
     * @return \Orm\Zed\Afterpay\Persistence\SpyPaymentAfterpay
69
     */
70
    protected function getPaymentEntityByIdSalesOrder(int $idSalesOrder): SpyPaymentAfterpay
71
    {
72
        $afterpayPaymentEntity = $this->afterpayQueryContainer
73
            ->queryPaymentByIdSalesOrder($idSalesOrder)
74
            ->findOne();
75
76
        return $afterpayPaymentEntity;
77
    }
78
79
    /**
80
     * @param int $idSalesOrderItem
81
     * @param int $idPayment
82
     *
83
     * @return \Orm\Zed\Afterpay\Persistence\SpyPaymentAfterpayOrderItem
84
     */
85
    protected function getPaymentOrderItemEntityByIdSalesOrderItemAndIdPayment(int $idSalesOrderItem, int $idPayment): SpyPaymentAfterpayOrderItem
86
    {
87
        $afterpayPaymentOrderItemEntity = $this->afterpayQueryContainer
88
            ->queryPaymentOrderItemByIdSalesOrderAndIdPayment($idSalesOrderItem, $idPayment)
89
            ->findOne();
90
        return $afterpayPaymentOrderItemEntity;
91
    }
92
}
93