OrderToCallConverter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 18
c 3
b 0
f 0
dl 0
loc 39
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCheckoutId() 0 7 2
A convert() 0 18 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\AfterPay\Communication\Converter;
9
10
use Generated\Shared\Transfer\AfterPayCallTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\AfterPayCallTransfer 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
13
class OrderToCallConverter implements OrderToCallConverterInterface
14
{
15
    /**
16
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
17
     *
18
     * @return \Generated\Shared\Transfer\AfterPayCallTransfer
19
     */
20
    public function convert(OrderTransfer $orderTransfer): AfterPayCallTransfer
21
    {
22
        /** @var \Generated\Shared\Transfer\PaymentTransfer $paymentTransfer */
23
        $paymentTransfer = $orderTransfer->getPayments()->offsetGet(0);
24
25
        return (new AfterPayCallTransfer())
26
            ->setOrderReference($orderTransfer->getOrderReference())
27
            ->setIdSalesOrder($orderTransfer->getIdSalesOrder())
28
            ->setEmail($orderTransfer->getEmail())
29
            ->setItems($orderTransfer->getItems())
30
            ->setBillingAddress($orderTransfer->getBillingAddress())
31
            ->setShippingAddress($orderTransfer->getShippingAddress())
32
            ->setTotals($orderTransfer->getTotals())
33
            ->setPaymentMethod($paymentTransfer->getPaymentMethod())
34
            ->setExpenses($orderTransfer->getExpenses())
35
            ->setCheckoutId($this->getCheckoutId($orderTransfer))
36
            ->setPayments($orderTransfer->getPayments())
37
            ->setCurrency($orderTransfer->getCurrencyIsoCode());
38
    }
39
40
    /**
41
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
42
     *
43
     * @return string|null
44
     */
45
    protected function getCheckoutId(OrderTransfer $orderTransfer): ?string
46
    {
47
        if ($orderTransfer->getAfterPayPayment()) {
48
            return $orderTransfer->getAfterPayPayment()->getIdCheckout();
49
        }
50
51
        return null;
52
    }
53
}
54