Passed
Pull Request — feature/ECO-948-renaming-and-r... (#7)
by Andrey
04:36 queued 01:50
created

RefundOrderModel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A refundPayment() 0 12 3
A __construct() 0 5 1
1
<?php
2
3
/**
4
 * Apache OSL-2
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\AmazonPay\Business\Order;
9
10
use Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay 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 SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToRefundInterface;
12
13
class RefundOrderModel implements RefundOrderInterface
14
{
15
    /**
16
     * @var \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToRefundInterface
17
     */
18
    protected $refundFacade;
19
20
    /**
21
     * @param \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToRefundInterface $refundFacade
22
     */
23
    public function __construct(
24
        AmazonPayToRefundInterface $refundFacade
25
    ) {
26
27
        $this->refundFacade = $refundFacade;
28
    }
29
30
    /**
31
     * @param \Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay $paymentEntity
32
     *
33
     * @return void
34
     */
35
    public function refundPayment(SpyPaymentAmazonpay $paymentEntity)
36
    {
37
        /** @var \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $items */
38
        $items = [];
39
40
        foreach ($paymentEntity->getSpyPaymentAmazonpaySalesOrderItems() as $amazonpaySalesOrderItem) {
41
            $items[] = $amazonpaySalesOrderItem->getSpySalesOrderItem();
42
        }
43
44
        if (count($items) > 0) {
45
            $refundTransfer = $this->refundFacade->calculateRefund($items, $items[0]->getOrder());
46
            $this->refundFacade->saveRefund($refundTransfer);
47
        }
48
    }
49
}
50