Passed
Push[email protected] ( 6f3704 )
by Bruno
03:10
created

TokenUiComponentProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getComponentForToken() 0 15 2
A __construct() 0 4 1
1
<?php
2
/**
3
 * Copyright © Wirecard Brasil. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See COPYING.txt for license details.
7
 */
8
9
namespace Moip\Magento2\Model\Ui\Vault\Adminhtml;
10
11
12
use Magento\Framework\View\Element\Template;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\View\Element\Template 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...
13
use Magento\Vault\Api\Data\PaymentTokenInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Vault\Api\Data\PaymentTokenInterface 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...
14
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...
15
use Magento\Vault\Model\Ui\TokenUiComponentProviderInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Vault\Model\Ui\T...ponentProviderInterface 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 Moip\Magento2\Model\Ui\ConfigProviderCc;
17
18
class TokenUiComponentProvider implements TokenUiComponentProviderInterface
19
{
20
    /**
21
     * @var TokenUiComponentInterfaceFactory
22
     */
23
    private $componentFactory;
24
    
25
26
    /**
27
     * TokenUiComponentProvider constructor.
28
     *
29
     * @param TokenUiComponentInterfaceFactory $componentFactory
30
     */
31
    public function __construct(
32
        TokenUiComponentInterfaceFactory $componentFactory
33
    ) {
34
        $this->componentFactory = $componentFactory;
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function getComponentForToken(PaymentTokenInterface $paymentToken)
41
    {
42
        $details = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
43
        $component = $this->componentFactory->create(
44
            [
45
                'config' => [
46
                    'code' => ConfigProviderCc::VAULT_CODE,
47
                    TokenUiComponentProviderInterface::COMPONENT_DETAILS => $details,
48
                    TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash(),
49
                    'template' => 'Moip_Magento2::form/vault.phtml'
50
                ],
51
                'name' => Template::class
52
            ]
53
        );
54
        return $component;
55
    }
56
}