TokenUiComponentProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getComponentForToken() 0 16 2
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;
10
11
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...
12
use Magento\Vault\Model\Ui\TokenUiComponentInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Vault\Model\Ui\TokenUiComponentInterface 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
16
class TokenUiComponentProvider implements TokenUiComponentProviderInterface
17
{
18
    /**
19
     * @var TokenUiComponentInterfaceFactory
20
     */
21
    private $componentFactory;
22
23
    /**
24
     * @param TokenUiComponentInterfaceFactory $componentFactory
25
     */
26
    public function __construct(
27
        TokenUiComponentInterfaceFactory $componentFactory
28
    ) {
29
        $this->componentFactory = $componentFactory;
30
    }
31
32
    /**
33
     * Get UI component for token.
34
     *
35
     * @param PaymentTokenInterface $paymentToken
36
     *
37
     * @return TokenUiComponentInterface
38
     */
39
    public function getComponentForToken(PaymentTokenInterface $paymentToken)
40
    {
41
        $jsonDetails = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
42
        $component = $this->componentFactory->create(
43
            [
44
                'config' => [
45
                    // phpcs:ignore Generic.Files.LineLength
46
                    'code'                                                   => ConfigProviderBase::METHOD_CODE_CC_VAULT,
47
                    TokenUiComponentProviderInterface::COMPONENT_DETAILS     => $jsonDetails,
48
                    TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash(),
49
                ],
50
                'name' => 'Moip_Magento2/js/view/payment/method-renderer/vault',
51
            ]
52
        );
53
54
        return $component;
55
    }
56
}
57