Passed
Push — master ( 2fd05c...9d8025 )
by Bruno
02:00
created

ConfigCcVault   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 21.28 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 10
loc 47
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A useCvv() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Gateway\Config;
10
11
use Magento\Framework\App\Config\ScopeConfigInterface;
12
use Magento\Framework\Exception\InputException;
13
use Magento\Framework\Exception\NoSuchEntityException;
14
use Magento\Store\Model\ScopeInterface;
15
16
class ConfigCcVault extends \Magento\Payment\Gateway\Config\Config
17
{
18
    /**
19
     * CVV Enabled - Cc Vault.
20
     *
21
     * @const string
22
     */
23
    const CVV_ENABLED = 'cvv_enabled';
24
25
    /**
26
     * Method Code - Cc Vault.
27
     *
28
     * @const string
29
     */
30
    const METHOD = 'moip_magento2_cc_vault';
31
32
    /**
33
     * Config constructor.
34
     *
35
     * @param ScopeConfigInterface $scopeConfig
36
     * @param null                 $methodCode
37
     */
38
    public function __construct(
39
        ScopeConfigInterface $scopeConfig,
40
        $methodCode = null
41
    ) {
42
        \Magento\Payment\Gateway\Config\Config::__construct($scopeConfig, $methodCode);
43
        $this->scopeConfig = $scopeConfig;
44
    }
45
46
    /**
47
     * @throws InputException
48
     * @throws NoSuchEntityException
49
     *
50
     * @return bool
51
     */
52 View Code Duplication
    public function useCvv($storeId = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54
        $pathPattern = 'payment/%s/%s';
55
56
        return (bool) $this->scopeConfig->getValue(
57
            sprintf($pathPattern, self::METHOD, self::CVV_ENABLED),
58
            ScopeInterface::SCOPE_STORE,
59
            $storeId
60
        );
61
    }
62
}
63