Passed
Branch [email protected] (3810d0)
by Bruno
11:09
created

ConfigTwoCc::getTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
declare(strict_types=1);
9
10
namespace Getnet\PaymentMagento\Gateway\Config;
11
12
use Magento\Framework\App\Config\ScopeConfigInterface;
13
use Magento\Framework\Serialize\Serializer\Json;
14
use Magento\Payment\Gateway\Config\Config as PaymentConfig;
15
use Magento\Store\Model\ScopeInterface;
16
17
/**
18
 * Class ConfigTwoCc - Returns form of payment configuration properties.
19
 */
20
class ConfigTwoCc extends PaymentConfig
21
{
22
    /**
23
     * @const string
24
     */
25
    public const METHOD = 'getnet_paymentmagento_two_cc';
26
27
    /**
28
     * @const string
29
     */
30
    public const CC_TYPES = 'payment/getnet_paymentmagento_two_cc/cctypes';
31
32
    /**
33
     * @const string
34
     */
35
    public const CVV_ENABLED = 'cvv_enabled';
36
37
    /**
38
     * @const string
39
     */
40
    public const ACTIVE = 'active';
41
42
    /**
43
     * @const string
44
     */
45
    public const TITLE = 'title';
46
47
    /**
48
     * @const string
49
     */
50
    public const CC_MAPPER = 'cctypes_mapper';
51
52
    /**
53
     * @const string
54
     */
55
    public const USE_GET_TAX_DOCUMENT = 'get_tax_document';
56
57
    /**
58
     * @const string
59
     */
60
    public const USE_GET_PHONE = 'get_phone';
61
62
    /**
63
     * @const string
64
     */
65
    public const USE_FRAUD_MANAGER = 'fraud_manager';
66
67
    /**
68
     * @const string
69
     */
70
    public const INSTALL_WITH_INTEREST = 'INSTALL_WITH_INTEREST';
71
72
    /**
73
     * @const string
74
     */
75
    public const INSTALL_NO_INTEREST = 'INSTALL_NO_INTEREST';
76
77
    /**
78
     * @const string
79
     */
80
    public const INSTALL_FULL = 'FULL';
81
82
    /**
83
     * @const string
84
     */
85
    public const PAYMENT_ACTION = 'payment_action';
86
87
    /**
88
     * @var ScopeConfigInterface
89
     */
90
    protected $scopeConfig;
91
92
    /**
93
     * @var Json
94
     */
95
    protected $json;
96
97
    /**
98
     * @param ScopeConfigInterface $scopeConfig
99
     * @param Json                 $json
100
     * @param string               $methodCode
101
     */
102
    public function __construct(
103
        ScopeConfigInterface $scopeConfig,
104
        Json $json,
105
        $methodCode = self::METHOD
106
    ) {
107
        parent::__construct($scopeConfig, $methodCode);
108
        $this->scopeConfig = $scopeConfig;
109
        $this->json = $json;
110
    }
111
112
    /**
113
     * Get Payment configuration status.
114
     *
115
     * @param int|null $storeId
116
     *
117
     * @return bool
118
     */
119
    public function isActive($storeId = null): bool
120
    {
121
        $pathPattern = 'payment/%s/%s';
122
123
        return (bool) $this->scopeConfig->getValue(
124
            sprintf($pathPattern, self::METHOD, self::ACTIVE),
125
            ScopeInterface::SCOPE_STORE,
126
            $storeId
127
        );
128
    }
129
130
    /**
131
     * Get title of payment.
132
     *
133
     * @param int|null $storeId
134
     *
135
     * @return string|null
136
     */
137
    public function getTitle($storeId = null): ?string
138
    {
139
        $pathPattern = 'payment/%s/%s';
140
141
        return $this->scopeConfig->getValue(
142
            sprintf($pathPattern, self::METHOD, self::TITLE),
143
            ScopeInterface::SCOPE_STORE,
144
            $storeId
145
        );
146
    }
147
}
148