PaymentReader   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 72
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getPaymentByIdSalesOrder() 0 6 1
A getPaymentOrderItemByIdSalesOrderItemAndIdPayment() 0 9 1
A getPaymentEntityByIdSalesOrder() 0 7 1
A getPaymentOrderItemEntityByIdSalesOrderItemAndIdPayment() 0 7 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\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
        return (new AfterPayPaymentTransfer())
41
            ->fromArray($afterPayPaymentEntity->toArray(), true);
42
    }
43
44
    /**
45
     * @param int $idSalesOrderItem
46
     * @param int $idPayment
47
     *
48
     * @return \Generated\Shared\Transfer\AfterPayPaymentOrderItemTransfer
49
     */
50
    public function getPaymentOrderItemByIdSalesOrderItemAndIdPayment(int $idSalesOrderItem, int $idPayment): AfterPayPaymentOrderItemTransfer
51
    {
52
        $afterPayPaymentOrderItemEntity = $this->getPaymentOrderItemEntityByIdSalesOrderItemAndIdPayment(
53
            $idSalesOrderItem,
54
            $idPayment,
55
        );
56
57
        return (new AfterPayPaymentOrderItemTransfer())
58
            ->fromArray($afterPayPaymentOrderItemEntity->toArray(), true);
59
    }
60
61
    /**
62
     * @param int $idSalesOrder
63
     *
64
     * @return \Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPay
65
     */
66
    protected function getPaymentEntityByIdSalesOrder(int $idSalesOrder): SpyPaymentAfterPay
67
    {
68
        $afterPayPaymentEntity = $this->afterPayQueryContainer
69
            ->queryPaymentByIdSalesOrder($idSalesOrder)
70
            ->findOne();
71
72
        return $afterPayPaymentEntity;
73
    }
74
75
    /**
76
     * @param int $idSalesOrderItem
77
     * @param int $idPayment
78
     *
79
     * @return \Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPayOrderItem
80
     */
81
    protected function getPaymentOrderItemEntityByIdSalesOrderItemAndIdPayment(int $idSalesOrderItem, int $idPayment): SpyPaymentAfterPayOrderItem
82
    {
83
        $afterPayPaymentOrderItemEntity = $this->afterPayQueryContainer
84
            ->queryPaymentOrderItemByIdSalesOrderAndIdPayment($idSalesOrderItem, $idPayment)
85
            ->findOne();
86
87
        return $afterPayPaymentOrderItemEntity;
88
    }
89
}
90