AbstractCommandHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 2
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\Computop\Business\Oms\Command;
9
10
use Generated\Shared\Transfer\ComputopApiHeaderPaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...piHeaderPaymentTransfer 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 Generated\Shared\Transfer\OrderTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\OrderTransfer 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 SprykerEco\Zed\Computop\Business\Oms\Command\Manager\ManagerInterface;
13
use SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface;
14
15
abstract class AbstractCommandHandler implements CommandHandlerInterface
16
{
17
    /**
18
     * @var \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface
19
     */
20
    protected $handler;
21
22
    /**
23
     * @var \SprykerEco\Zed\Computop\Business\Oms\Command\Manager\ManagerInterface
24
     */
25
    protected $manager;
26
27
    /**
28
     * @param \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface $handler
29
     * @param \SprykerEco\Zed\Computop\Business\Oms\Command\Manager\ManagerInterface $manager
30
     */
31
    public function __construct(
32
        HandlerInterface $handler,
33
        ManagerInterface $manager
34
    ) {
35
        $this->handler = $handler;
36
        $this->manager = $manager;
37
    }
38
39
    /**
40
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
41
     *
42
     * @return \Generated\Shared\Transfer\ComputopApiHeaderPaymentTransfer
43
     */
44
    protected function createComputopHeaderPayment(OrderTransfer $orderTransfer)
45
    {
46
        $headerPayment = new ComputopApiHeaderPaymentTransfer();
47
        $savedComputopEntity = $this->manager->getSavedComputopEntity($orderTransfer->getIdSalesOrder());
48
        $headerPayment->fromArray($savedComputopEntity->toArray(), true);
49
        $headerPayment->setAmount($this->getAmount($orderTransfer));
50
51
        return $headerPayment;
52
    }
53
54
    /**
55
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
56
     *
57
     * @return int
58
     */
59
    protected function getAmount(OrderTransfer $orderTransfer)
60
    {
61
        return $orderTransfer->getTotals()->getGrandTotal();
62
    }
63
}
64