Completed
Pull Request — master (#28)
by Vitaliy
02:51
created

Input::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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