PartialCaptureCommandByOrderPlugin::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 16
rs 9.9666
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Payone\Communication\Plugin\Oms\Command;
9
10
use Generated\Shared\Transfer\PayonePartialOperationRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...perationRequestTransfer 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;
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...
12
use Spryker\Zed\Kernel\Communication\AbstractPlugin;
13
use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject;
14
use Spryker\Zed\Oms\Dependency\Plugin\Command\CommandByOrderInterface;
15
16
/**
17
 * @method \SprykerEco\Zed\Payone\Business\PayoneFacadeInterface getFacade()
18
 * @method \SprykerEco\Zed\Payone\Communication\PayoneCommunicationFactory getFactory()
19
 * @method \SprykerEco\Zed\Payone\PayoneConfig getConfig()
20
 * @method \SprykerEco\Zed\Payone\Persistence\PayoneQueryContainerInterface getQueryContainer()
21
 */
22
class PartialCaptureCommandByOrderPlugin extends AbstractPlugin implements CommandByOrderInterface
23
{
24
    /**
25
     * {@inheritDoc}
26
     * - Performs partial capture call to Payone API.
27
     *
28
     * @api
29
     *
30
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $orderItems
31
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
32
     * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
33
     *
34
     * @return array
35
     */
36
    public function run(array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data)
37
    {
38
        $orderTransfer = $this->getFactory()
39
            ->getSalesFacade()
40
            ->getOrderByIdSalesOrder($orderEntity->getIdSalesOrder());
41
42
        $payonePartialOperationTransfer = (new PayonePartialOperationRequestTransfer())
43
            ->setOrder($orderTransfer);
44
45
        foreach ($orderItems as $orderItem) {
46
            $payonePartialOperationTransfer->addSalesOrderItemId($orderItem->getIdSalesOrderItem());
47
        }
48
49
        $this->getFacade()->executePartialCapture($payonePartialOperationTransfer);
50
51
        return [];
52
    }
53
}
54