Input::setValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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