Passed
Push[email protected] ( 6f4930...6fef5b )
by Bruno
13:24 queued 10:12
created

TokenUiComponentProvider::getComponentForToken()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 16
rs 9.9666
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
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...
12
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...
13
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...
14
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...
15
use Moip\Magento2\Model\Ui\ConfigProviderCc;
16
17
class TokenUiComponentProvider implements TokenUiComponentProviderInterface
18
{
19
    /**
20
     * @var TokenUiComponentInterfaceFactory
21
     */
22
    private $componentFactory;
23
24
    /**
25
     * TokenUiComponentProvider constructor.
26
     *
27
     * @param TokenUiComponentInterfaceFactory $componentFactory
28
     */
29
    public function __construct(
30
        TokenUiComponentInterfaceFactory $componentFactory
31
    ) {
32
        $this->componentFactory = $componentFactory;
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38
    public function getComponentForToken(PaymentTokenInterface $paymentToken)
39
    {
40
        $details = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
41
        $component = $this->componentFactory->create(
42
            [
43
                'config' => [
44
                    'code'                                                   => ConfigProviderCc::VAULT_CODE,
45
                    TokenUiComponentProviderInterface::COMPONENT_DETAILS     => $details,
46
                    TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash(),
47
                    'template'                                               => 'Moip_Magento2::form/vault.phtml',
48
                ],
49
                'name' => Template::class,
50
            ]
51
        );
52
53
        return $component;
54
    }
55
}
56