Passed
Pull Request — dev (#9)
by Andrey
08:48 queued 04:25
created

AmazonpayOrderInfoHydrator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hydrateOrderInfo() 0 4 1
A __construct() 0 3 1
A getAmazonpayOrderInfo() 0 7 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\Business\Order;
9
10
use Generated\Shared\Transfer\AmazonpayOrderInfoTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...zonpayOrderInfoTransfer 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;
1 ignored issue
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\AmazonPay\Persistence\AmazonPayQueryContainerInterface;
13
14
class AmazonpayOrderInfoHydrator implements AmazonpayOrderInfoHydratorInterface
15
{
16
    /**
17
     * @var \SprykerEco\Zed\AmazonPay\Persistence\AmazonPayQueryContainerInterface
18
     */
19
    protected $queryContainer;
20
21
    /**
22
     * @param \SprykerEco\Zed\AmazonPay\Persistence\AmazonPayQueryContainerInterface $queryContainer
23
     */
24
    public function __construct(AmazonPayQueryContainerInterface $queryContainer)
25
    {
26
        $this->queryContainer = $queryContainer;
27
    }
28
29
    /**
30
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
31
     *
32
     * @return \Generated\Shared\Transfer\OrderTransfer
33
     */
34
    public function hydrateOrderInfo(OrderTransfer $orderTransfer)
35
    {
36
        $orderTransfer->setAmazonpayOrderInfo($this->getAmazonpayOrderInfo($orderTransfer));
37
        return $orderTransfer;
38
    }
39
40
    /**
41
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
42
     *
43
     * @return \Generated\Shared\Transfer\AmazonpayOrderInfoTransfer
44
     */
45
    protected function getAmazonpayOrderInfo(OrderTransfer $orderTransfer)
46
    {
47
        $payment = $this->queryContainer->queryPaymentBySalesOrderItemId($orderTransfer->getItems()[0]->getIdSalesOrderItem())
48
            ->findOne();
49
        $amazonpayOrderInfo = new AmazonpayOrderInfoTransfer();
50
        $amazonpayOrderInfo->fromArray($payment->toArray(), true);
51
        return $amazonpayOrderInfo;
52
    }
53
}
54