Completed
Push — master ( 15d409...38a590 )
by Shcherbak
05:57 queued 13s
created

Input::setValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
ccs 4
cts 4
cp 1
cc 1
eloc 4
nc 1
nop 1
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 Base {
9
10
    protected $tag = 'input';
11
12
    protected $type = 'text';
13
14
15
    /**
16
     * @return string
17
     */
18 1
    public function getType() {
19 1
      if (empty($this->attributes['type'])) {
20
        $this->attributes['type'] = $this->type;
21
      }
22
23 1
      return $this->attributes['type'];
24
    }
25
26
27
    /**
28
     * @param string $type
29
     * @return $this
30
     */
31 8
    public function setType($type) {
32 8
      $this->attributes['type'] = $type;
33 8
      return $this;
34
    }
35
36
37
    /**
38
     * @param $value
39
     * @return $this
40
     */
41 9
    public function setValue($value) {
42 9
      parent::setValue($value);
43 9
      $this->setAttribute('value', $this->value);
44 9
      return $this;
45
    }
46
47
48
    /**
49
     *
50
     * @return string
51
     */
52 1
    public function render() {
53 1
      $this->setAttribute('type', $this->getType());
54 1
      return parent::render();
55
    }
56
57
  }