Issues (1006)

Adminhtml/Config/Form/Field/CreditcardTemplate.php (7 issues)

1
<?php
2
3
/**
4
 * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * PHP version 5
18
 *
19
 * @category  Payone
20
 * @package   Payone_Magento2_Plugin
21
 * @author    FATCHIP GmbH <[email protected]>
22
 * @copyright 2003 - 2016 Payone GmbH
23
 * @license   <http://www.gnu.org/licenses/> GNU Lesser General Public License
24
 * @link      http://www.payone.de
25
 */
26
27
namespace Payone\Core\Block\Adminhtml\Config\Form\Field;
28
29
/**
30
 * Admin-block for Iframe creditcard configuration
31
 */
32
class CreditcardTemplate extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
0 ignored issues
show
The type Magento\Config\Block\Sys...rray\AbstractFieldArray 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...
33
{
34
    /**
35
     * Default configuration
36
     *
37
     * @var array
38
     */
39
    protected $aDefaultConfig = [
40
        'Number_type' => 'tel',
41
        'Number_count' => '30',
42
        'Number_max' => '16',
43
        'Number_iframe' => 'standard',
44
        'Number_width' => '202px',
45
        'Number_height' => '20px',
46
        'Number_style' => 'standard',
47
        'Number_css' => '',
48
        'CVC_type' => 'tel',
49
        'CVC_count' => '30',
50
        'CVC_max' => '4',
51
        'CVC_iframe' => 'standard',
52
        'CVC_width' => '202px',
53
        'CVC_height' => '20px',
54
        'CVC_style' => 'standard',
55
        'CVC_css' => '',
56
        'Month_type' => 'select',
57
        'Month_count' => '3',
58
        'Month_max' => '2',
59
        'Month_iframe' => 'custom',
60
        'Month_width' => '120px',
61
        'Month_height' => '20px',
62
        'Month_style' => 'standard',
63
        'Month_css' => '',
64
        'Year_type' => 'select',
65
        'Year_count' => '5',
66
        'Year_max' => '4',
67
        'Year_iframe' => 'custom',
68
        'Year_width' => '120px',
69
        'Year_height' => '20px',
70
        'Year_style' => 'standard',
71
        'Year_css' => '',
72
        'Iframe_width' => '365px',
73
        'Iframe_height' => '30px',
74
        'Standard_input' => "width:223px;height:30px;padding: 0 9px;font-size:14px;font-family:'Helvetica Neue',Verdana,Arial,sans-serif;",
75
        'Standard_selection' => 'width:100px;',
76
    ];
77
78
    /**
79
     * Template
80
     *
81
     * @var string
82
     */
83
    protected $_template = 'Payone_Core::system/config/form/field/creditcard_template.phtml';
84
85
    /**
86
     * Initialise form fields
87
     *
88
     * @return void
89
     */
90
    protected function _construct()
91
    {
92
        $this->addColumn('txaction', ['label' => __('Transactionstatus-message')]);
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

92
        $this->addColumn('txaction', ['label' => /** @scrutinizer ignore-call */ __('Transactionstatus-message')]);
Loading history...
93
        $this->_addAfter = false;
0 ignored issues
show
Bug Best Practice introduced by
The property _addAfter does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
94
        $this->_addButtonLabel = __('Add Minimum Qty');
0 ignored issues
show
Bug Best Practice introduced by
The property _addButtonLabel does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
95
        parent::_construct();
96
    }
97
98
    /**
99
     * Get all field-types
100
     *
101
     * @return array
102
     */
103
    public function getCCFields()
104
    {
105
        return [
106
            'Number',
107
            'CVC',
108
            'Month',
109
            'Year',
110
        ];
111
    }
112
113
    /**
114
     * Get available styles for dropdown
115
     *
116
     * @return array
117
     */
118
    public function getCCStyles()
119
    {
120
        return [
121
            'standard' => __('Standard'),
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

121
            'standard' => /** @scrutinizer ignore-call */ __('Standard'),
Loading history...
122
            'custom' => __('Custom'),
123
        ];
124
    }
125
126
    /**
127
     * Get available types for dropdown
128
     *
129
     * @param  string $sField
130
     * @return array
131
     */
132
    public function getCCTypes($sField)
133
    {
134
        $aTypes = [];
135
        if ($sField == 'Month' || $sField == 'Year') {
136
            $aTypes['select'] = __('Select');
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

136
            $aTypes['select'] = /** @scrutinizer ignore-call */ __('Select');
Loading history...
137
        }
138
        $aTypes['tel'] = __('Numeric');
139
        $aTypes['password'] = __('Password');
140
        $aTypes['text'] = __('Text');
141
        return $aTypes;
142
    }
143
144
    /**
145
     * Get configured value or default value
146
     *
147
     * @param  string $sIdent
148
     * @return string
149
     */
150
    public function fcpoGetValue($sIdent)
151
    {
152
        $sReturn = '';
153
154
        $aValues = $this->getElement()->getValue();
155
        if (is_array($aValues) === false) { // no array given? -> value from config.xml
156
            $aValues = json_decode($aValues, true); // convert string to array
0 ignored issues
show
$aValues of type array is incompatible with the type string expected by parameter $json of json_decode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

156
            $aValues = json_decode(/** @scrutinizer ignore-type */ $aValues, true); // convert string to array
Loading history...
157
        }
158
159
        if (isset($aValues[$sIdent])) {
160
            $sReturn = $aValues[$sIdent];
161
        } elseif (isset($this->aDefaultConfig[$sIdent])) {
162
            $sReturn = $this->aDefaultConfig[$sIdent];
163
        }
164
        $sReturn = str_replace('"', "&quot;", $sReturn);
165
        return $sReturn;
166
    }
167
}
168