Completed
Push — master ( 849039...32eb69 )
by Shcherbak
03:58
created

Input::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
  namespace Fiv\Form\Element;
4
5
  /**
6
   * @author Ivan Shcherbak <[email protected]> 7/11/14
7
   */
8
  class Input extends BaseElement {
9
10
    /**
11
     * @var string
12
     */
13
    protected $tag = 'input';
14
15
    /**
16
     * @var array
17
     */
18
    protected $attributes = [
19
      'type' => 'text',
20
    ];
21
22
23
    /**
24
     * @return null|string
25
     */
26 3
    public function getType() {
27 3
      if (!empty($this->attributes['type'])) {
28 3
        return $this->attributes['type'];
29
      }
30
31
      return null;
32
    }
33
34
35
    /**
36
     * Alias of $this->setAttribute('type' 'text');
37
     *
38
     * @param string $type
39
     * @return $this
40
     */
41 4
    public function setType($type) {
42 4
      $this->attributes['type'] = $type;
43 4
      return $this;
44
    }
45
46
47
    /**
48
     * @param $value
49
     * @return $this
50
     */
51 13
    public function setValue($value) {
52 13
      $this->setAttribute('value', $value);
53 13
      return $this;
54
    }
55
56
    /**
57
     *
58
     * @return string
59
     */
60 3
    public function render() {
61 3
      $this->setAttribute('type', $this->getType());
62 3
      return parent::render();
63
    }
64
65
  }