TokenUiComponentProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 46
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getComponentForToken() 0 17 1
1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
9
namespace Getnet\PaymentMagento\Model\Ui\Vault\Adminhtml;
10
11
use Getnet\PaymentMagento\Model\Ui\ConfigProviderCc;
12
use Magento\Framework\Serialize\Serializer\Json;
13
use Magento\Framework\View\Element\Template;
14
use Magento\Vault\Api\Data\PaymentTokenInterface;
15
use Magento\Vault\Model\Ui\TokenUiComponentInterfaceFactory;
0 ignored issues
show
Bug introduced by
The type Magento\Vault\Model\Ui\T...mponentInterfaceFactory 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...
16
use Magento\Vault\Model\Ui\TokenUiComponentProviderInterface;
17
18
/**
19
 * Class TokenUiComponentProvider - Defines properties of the payment form.
20
 *
21
 * @SuppressWarnings(PHPCPD)
22
 */
23
class TokenUiComponentProvider implements TokenUiComponentProviderInterface
24
{
25
    /**
26
     * @var TokenUiComponentInterfaceFactory
27
     */
28
    private $componentFactory;
29
30
    /**
31
     * @var Json
32
     */
33
    protected $json;
34
35
    /**
36
     * TokenUiComponentProvider constructor.
37
     *
38
     * @param TokenUiComponentInterfaceFactory $componentFactory
39
     * @param Json                             $json
40
     */
41
    public function __construct(
42
        TokenUiComponentInterfaceFactory $componentFactory,
43
        Json $json
44
    ) {
45
        $this->componentFactory = $componentFactory;
46
        $this->json = $json;
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52
    public function getComponentForToken(PaymentTokenInterface $paymentToken)
53
    {
54
        $details = $this->json->unserialize($paymentToken->getTokenDetails());
55
        $component = $this->componentFactory->create(
56
            [
57
                'config' => [
58
                    'code'                                                   => ConfigProviderCc::VAULT_CODE,
59
                    TokenUiComponentProviderInterface::COMPONENT_DETAILS     => $details,
60
                    TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash(),
61
                    // phpcs:ignore Generic.Files.LineLength
62
                    'template'                                               => 'Getnet_PaymentMagento::form/vault.phtml',
63
                ],
64
                'name' => Template::class,
65
            ]
66
        );
67
68
        return $component;
69
    }
70
}
71