Completed
Push — master ( eaf845...272b76 )
by Oleksandr
13s queued 10s
created

CaptureOmsCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 44
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A execute() 0 13 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\CrefoPay\Communication\Oms\Command;
9
10
use Orm\Zed\Sales\Persistence\SpySalesOrder;
0 ignored issues
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...
11
use Orm\Zed\Sales\Persistence\SpySalesOrderItem;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Sales\Persistence\SpySalesOrderItem 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\Zed\CrefoPay\Business\CrefoPayFacadeInterface;
14
use SprykerEco\Zed\CrefoPay\Communication\Oms\CrefoPayOmsMapperInterface;
15
16
class CaptureOmsCommand implements CrefoPayOmsCommandByOrderInterface
17
{
18
    /**
19
     * @var \SprykerEco\Zed\CrefoPay\Communication\Oms\CrefoPayOmsMapperInterface
20
     */
21
    protected $mapper;
22
23
    /**
24
     * @var \SprykerEco\Zed\CrefoPay\Business\CrefoPayFacadeInterface
25
     */
26
    protected $facade;
27
28
    /**
29
     * @param \SprykerEco\Zed\CrefoPay\Communication\Oms\CrefoPayOmsMapperInterface $mapper
30
     * @param \SprykerEco\Zed\CrefoPay\Business\CrefoPayFacadeInterface $facade
31
     */
32
    public function __construct(
33
        CrefoPayOmsMapperInterface $mapper,
34
        CrefoPayFacadeInterface $facade
35
    ) {
36
        $this->mapper = $mapper;
37
        $this->facade = $facade;
38
    }
39
40
    /**
41
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $salesOrderItems
42
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $salesOrderEntity
43
     * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
44
     *
45
     * @return void
46
     */
47
    public function execute(array $salesOrderItems, SpySalesOrder $salesOrderEntity, ReadOnlyArrayObject $data): void
48
    {
49
        $orderTransfer = $this->mapper->mapSpySalesOrderToOrderTransfer($salesOrderEntity);
50
51
        $salesOrderItemIds = array_map(
52
            function (SpySalesOrderItem $orderItem) {
53
                return $orderItem->getIdSalesOrderItem();
54
            },
55
            $salesOrderItems
56
        );
57
58
        $this->facade
59
            ->executeCaptureOmsCommand($orderTransfer, $salesOrderItemIds);
60
    }
61
}
62