Passed
Push — master ( c01df0...b2280f )
by Cesar
10:38 queued 06:42
created

ConfigProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 16
dl 0
loc 52
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
1
<?php
2
3
namespace Pagantis\Pagantis\Model\Ui;
4
5
use Magento\Checkout\Model\ConfigProviderInterface;
6
use Magento\Checkout\Model\Session;
7
use Pagantis\Pagantis\Helper\ExtraConfig;
8
9
/**
10
 * Class ConfigProvider
11
 * @package Pagantis\Pagantis\Model\Ui
12
 */
13
final class ConfigProvider implements ConfigProviderInterface
14
{
15
    const CODE = 'pagantis';
16
17
    /**
18
     * @var \Magento\Payment\Model\MethodInterface
19
     */
20
    protected $method;
21
22
    /**
23
     * @var Session
24
     */
25
    protected $checkoutSession;
26
27
    /**
28
     * @var String
29
     */
30
    protected $extraConfig;
31
32
    /**
33
     * @var String
34
     */
35
    protected $assetRepository;
36
37
38
    public function __construct(
39
        \Magento\Payment\Helper\Data $paymentHelper,
40
        Session $checkoutSession,
41
        ExtraConfig $extraConfig,
42
        \Magento\Framework\View\Asset\Repository $assetRepository
43
    ) {
44
        $this->method = $paymentHelper->getMethodInstance(self::CODE);
45
        $this->checkoutSession = $checkoutSession;
46
        $this->extraConfig = $extraConfig->getExtraConfig();
0 ignored issues
show
Documentation Bug introduced by
It seems like $extraConfig->getExtraConfig() of type array or array is incompatible with the declared type string of property $extraConfig.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
        $this->assetRepository = $assetRepository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $assetRepository of type Magento\Framework\View\Asset\Repository is incompatible with the declared type string of property $assetRepository.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
48
    }
49
50
    /**
51
     * Retrieve assoc array of checkout configuration
52
     *
53
     * @return array
54
     */
55
    public function getConfig()
56
    {
57
        $quote = $this->checkoutSession->getQuote();
58
59
        return [
60
            'payment' => [
61
                self::CODE => [
62
                    'total' => $quote->getGrandTotal(),
63
                    'displayMode' => $this->method->getConfigData('display_mode'),
64
                    'title' => __($this->extraConfig['PAGANTIS_TITLE']),
65
                    'subtitle' => __($this->extraConfig['PAGANTIS_TITLE_EXTRA']),
66
                    'image' => $this->assetRepository->getUrl('Pagantis_Pagantis::logopagantis.png')
67
                ],
68
            ],
69
        ];
70
    }
71
}
72