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

Input   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 9
Bugs 1 Features 2
Metric Value
wmc 4
c 9
b 1
f 2
lcom 1
cbo 2
dl 0
loc 53
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 3 1
A setType() 0 4 1
A setValue() 0 4 1
A handle() 0 3 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
  }