Passed
Push — bugfix/ECO-1031-recent-review ( e58bbe...58e838 )
by Andrey
03:41
created

CancelOrderCommandPlugin   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 12 1
A cancelSalesOrder() 0 6 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\Communication\Plugin\Oms\Command;
9
10
use Generated\Shared\Transfer\AmazonpayCallTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\AmazonpayCallTransfer 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 Orm\Zed\Sales\Persistence\SpySalesOrder;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Sales\Persistence\SpySalesOrder 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 Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject;
13
use SprykerEco\Shared\AmazonPay\AmazonPayConfig;
14
15
/**
16
 * @method \SprykerEco\Zed\AmazonPay\Business\AmazonPayFacade getFacade()
17
 */
18
class CancelOrderCommandPlugin extends AbstractAmazonpayCommandPlugin
19
{
20
    /**
21
     * @param array $salesOrderItems
22
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
23
     * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
24
     *
25
     * @return array
26
     */
27
    public function run(array $salesOrderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data)
28
    {
29
        $amazonpayCallTransfer = $this->createAmazonpayCallTransfer(
30
            $this->getPayment($salesOrderItems)
31
        );
32
33
        $this->getFacade()->cancelOrder($amazonpayCallTransfer);
34
35
        $this->populateItems($amazonpayCallTransfer, $salesOrderItems);
36
        $this->cancelSalesOrder($amazonpayCallTransfer, $data);
37
38
        return [];
39
    }
40
41
    /**
42
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
43
     * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
44
     *
45
     * @return void
46
     */
47
    protected function cancelSalesOrder(AmazonpayCallTransfer $amazonpayCallTransfer, ReadOnlyArrayObject $data)
48
    {
49
        $this->getFacade()->triggerEventForRelatedItems(
50
            $amazonpayCallTransfer,
51
            $data->getArrayCopy(),
52
            AmazonPayConfig::OMS_EVENT_CANCEL
53
        );
54
    }
55
}
56