ActiveField   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 30
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A widget() 0 5 1
A init() 0 14 2
1
<?php
2
3
/**
4
 * @author Anton Tuyakhov <[email protected]>
5
 */
6
7
namespace tuyakhov\braintree;
8
9
use yii\helpers\Inflector;
10
11
class ActiveField extends \yii\bootstrap\ActiveField
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function init()
17
    {
18
        parent::init();
19
20
        $inputName = explode('_', $this->attribute);
21
        if (count($inputName) > 1) {
22
            $inputName[0] = $inputName[1];
23
        }
24
        $this->inputOptions = array_merge(
25
            [
26
                'data-braintree-name' => Inflector::underscore($inputName[0]),
27
                'autocomplete' => 'off',
28
            ],
29
            $this->inputOptions
30
        );
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function widget($class, $config = [])
37
    {
38
        $config = array_merge(['options' => $this->inputOptions], $config);
39
40
        return parent::widget($class, $config);
41
    }
42
}
43