Passed
Push — master ( eb0fcb...47bdab )
by Gabriel
04:01 queued 10s
created

Nip_Form_Button_Abstract   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 135
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 16
eloc 31
dl 0
loc 135
ccs 0
cts 42
cp 0
rs 10
c 1
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 5 1
A setId() 0 5 1
A render() 0 3 1
A getId() 0 3 1
A setForm() 0 5 1
A setName() 0 5 1
A getForm() 0 3 1
A init() 0 3 1
A setLabel() 0 5 1
A getValue() 0 3 1
A getType() 0 3 1
A getName() 0 3 1
A delAttrib() 0 6 1
A getLabel() 0 3 1
A __construct() 0 4 1
A getRenderer() 0 3 1
1
<?php
2
3
use Nip\Form\AbstractForm;
4
5
abstract class Nip_Form_Button_Abstract
6
{
7
    use \Nip\Form\Traits\HasClassTrait;
8
    use \Nip\Form\Traits\HasAttributesTrait;
9
10
    protected $_form;
11
    protected $_attribs;
12
    protected $_uniqueID;
13
14
    protected $_type = 'abstract';
15
16
    public function __construct($form)
17
    {
18
        $this->setForm($form);
19
        $this->init();
20
    }
21
22
    public function init()
23
    {
24
        $this->addClass('btn', 'btn-primary');
25
    }
26
27
    public function setId($id)
28
    {
29
        $this->setAttrib('id', $id);
30
31
        return $this;
32
    }
33
34
    public function getId()
35
    {
36
        return $this->getAttrib('id');
37
    }
38
39
    public function setName($name)
40
    {
41
        $this->setAttrib('name', $name);
42
43
        return $this;
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getName()
50
    {
51
        return $this->getAttrib('name');
52
    }
53
54
    /**
55
     * @param string $label
56
     * @return $this
57
     */
58
    public function setLabel($label)
59
    {
60
        $this->setAttrib('label', $label);
61
62
        return $this;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getLabel()
69
    {
70
        return $this->getAttrib('label');
71
    }
72
73
    /**
74
     * @param $value
75
     * @return $this
76
     */
77
    public function setValue($value)
78
    {
79
        $this->setAttrib('value', $value);
80
81
        return $this;
82
    }
83
84
    /**
85
     * @param string $requester
86
     * @return string
87
     */
88
    public function getValue($requester = 'abstract')
0 ignored issues
show
Unused Code introduced by
The parameter $requester is not used and could be removed. ( Ignorable by Annotation )

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

88
    public function getValue(/** @scrutinizer ignore-unused */ $requester = 'abstract')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
89
    {
90
        return $this->getAttrib('value');
91
    }
92
93
    /**
94
     * @param $key
95
     * @return bool
96
     */
97
    public function delAttrib($key)
98
    {
99
        $key = (string) $key;
100
        unset($this->_attribs[$key]);
101
102
        return true;
103
    }
104
105
    public function render()
106
    {
107
        return $this->getRenderer()->render($this);
108
    }
109
110
    public function getRenderer()
111
    {
112
        return $this->getForm()->getRenderer()->getButtonRenderer($this);
113
    }
114
115
    /**
116
     * @return AbstractForm
117
     */
118
    public function getForm()
119
    {
120
        return $this->_form;
121
    }
122
123
    /**
124
     * @param AbstractForm $form
125
     * @return $this
126
     */
127
    public function setForm(AbstractForm $form)
128
    {
129
        $this->_form = $form;
130
131
        return $this;
132
    }
133
134
    /**
135
     * @return string
136
     */
137
    public function getType()
138
    {
139
        return $this->_type;
140
    }
141
}
142