Info   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 85
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getPaymentInfoHtml() 0 3 1
A getFormattedAddress() 0 3 1
A __construct() 0 12 1
A getOrder() 0 3 1
A _prepareLayout() 0 5 1
1
<?php
2
/**
3
 * Copyright © 2021 O2TI. All rights reserved.
4
 *
5
 * @author  Bruno Elisei <[email protected]>
6
 * See LICENSE.txt for license details.
7
 */
8
9
namespace O2TI\ThemeFullCheckout\Block\Success;
10
11
use Magento\Framework\Registry;
12
use Magento\Framework\View\Element\Template\Context as TemplateContext;
13
use Magento\Payment\Helper\Data as PaymentHelper;
14
use Magento\Sales\Model\Order\Address;
15
use Magento\Sales\Model\Order\Address\Renderer as AddressRenderer;
16
17
/**
18
 * Info - Success page view comments form.
19
 */
20
class Info extends \Magento\Framework\View\Element\Template
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $_template = 'Magento_Sales::order/info.phtml';
26
27
    /**
28
     * @var Registry
29
     */
30
    protected $coreRegistry = null;
31
32
    /**
33
     * @var PaymentHelper
34
     */
35
    protected $paymentHelper;
36
37
    /**
38
     * @var AddressRenderer
39
     */
40
    protected $addressRenderer;
41
42
    /**
43
     * @param TemplateContext $context
44
     * @param Registry        $registry
45
     * @param PaymentHelper   $paymentHelper
46
     * @param AddressRenderer $addressRenderer
47
     * @param array           $data
48
     */
49
    public function __construct(
50
        TemplateContext $context,
51
        Registry $registry,
52
        PaymentHelper $paymentHelper,
53
        AddressRenderer $addressRenderer,
54
        array $data = []
55
    ) {
56
        $this->addressRenderer = $addressRenderer;
57
        $this->paymentHelper = $paymentHelper;
58
        $this->coreRegistry = $registry;
59
        $this->_isScopePrivate = true;
0 ignored issues
show
Deprecated Code introduced by
The property Magento\Framework\View\E...Block::$_isScopePrivate has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

59
        /** @scrutinizer ignore-deprecated */ $this->_isScopePrivate = true;
Loading history...
60
        parent::__construct($context, $data);
61
    }
62
63
    /**
64
     * Add Payment Info in Layout.
65
     *
66
     * @return void
67
     */
68
    protected function _prepareLayout()
69
    {
70
        $this->pageConfig->getTitle()->set(__('Success Page for Order #%1', $this->getOrder()->getRealOrderId()));
71
        $infoBlock = $this->paymentHelper->getInfoBlock($this->getOrder()->getPayment(), $this->getLayout());
0 ignored issues
show
Bug introduced by
It seems like $this->getOrder()->getPayment() can also be of type null; however, parameter $info of Magento\Payment\Helper\Data::getInfoBlock() does only seem to accept Magento\Payment\Model\InfoInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

71
        $infoBlock = $this->paymentHelper->getInfoBlock(/** @scrutinizer ignore-type */ $this->getOrder()->getPayment(), $this->getLayout());
Loading history...
72
        $this->setChild('payment_info', $infoBlock);
73
    }
74
75
    /**
76
     * Child Payment Info Html.
77
     *
78
     * @return string
79
     */
80
    public function getPaymentInfoHtml()
81
    {
82
        return $this->getChildHtml('payment_info');
83
    }
84
85
    /**
86
     * Retrieve current order model instance.
87
     *
88
     * @return \Magento\Sales\Model\Order
89
     */
90
    public function getOrder()
91
    {
92
        return $this->coreRegistry->registry('current_order');
0 ignored issues
show
Deprecated Code introduced by
The function Magento\Framework\Registry::registry() has been deprecated: 102.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

92
        return /** @scrutinizer ignore-deprecated */ $this->coreRegistry->registry('current_order');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
93
    }
94
95
    /**
96
     * Returns string with formatted address.
97
     *
98
     * @param Address $address
99
     *
100
     * @return null|string
101
     */
102
    public function getFormattedAddress(Address $address)
103
    {
104
        return $this->addressRenderer->format($address, 'html');
105
    }
106
}
107