Completed
Push — feature/eco-574/eco-2266-check... ( b72c03...e5ed68 )
by Ruslan
11s queued 10s
created

OrderToCallConverter::getCheckoutId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
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->getCustomer()->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
            ->setCurrency($orderTransfer->getCurrencyIsoCode());
37
    }
38
39
    /**
40
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
41
     *
42
     * @return string|null
43
     */
44
    protected function getCheckoutId(OrderTransfer $orderTransfer): ?string
45
    {
46
        if ($orderTransfer->getAfterPayPayment()) {
47
            return $orderTransfer->getAfterPayPayment()->getIdCheckout();
48
        }
49
50
        return null;
51
    }
52
}
53