Completed
Push — feature/ECO-1185-eco-ci ( 4da4ac...5d4add )
by Andrey
13:41 queued 10:25
created

CancelOrderCommandPlugin::cancelSalesOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
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\AmazonPayFacadeInterface getFacade()
17
 * @method \SprykerEco\Zed\AmazonPay\Business\AmazonPayBusinessFactory getFactory()
18
 */
19
class CancelOrderCommandPlugin extends AbstractAmazonpayCommandPlugin
20
{
21
    /**
22
     * @param array $salesOrderItems
23
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
24
     * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
25
     *
26
     * @return array
27
     */
28
    public function run(array $salesOrderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data)
29
    {
30
        $amazonpayCallTransfer = $this->createAmazonpayCallTransfer(
31
            $this->getPayment($salesOrderItems)
32
        );
33
34
        $this->getFacade()->cancelOrder($amazonpayCallTransfer);
35
36
        $this->populateItems($amazonpayCallTransfer, $salesOrderItems);
37
        $this->cancelSalesOrder($amazonpayCallTransfer, $data);
38
39
        return [];
40
    }
41
42
    /**
43
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
44
     * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
45
     *
46
     * @return void
47
     */
48
    protected function cancelSalesOrder(AmazonpayCallTransfer $amazonpayCallTransfer, ReadOnlyArrayObject $data)
49
    {
50
        $this->getFacade()->triggerEventForRelatedItems(
51
            $amazonpayCallTransfer,
52
            $data->getArrayCopy(),
53
            AmazonPayConfig::OMS_EVENT_CANCEL
54
        );
55
    }
56
}
57