Completed
Pull Request — master (#1)
by Derek Stephen
02:21
created

Text   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 6
dl 0
loc 41
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTag() 0 4 1
A init() 0 11 1
A getPlaceholder() 0 4 1
A setPlaceholder() 0 4 1
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 19/11/2016
5
 * Time: 21:37
6
 */
7
8
namespace Del\Form\Field;
9
10
use Del\Form\Filter\Adapter\FilterAdapterZf;
11
use Del\Form\Validator\Adapter\ValidatorAdapterZf;
12
use Zend\Filter\StringTrim;
13
use Zend\Filter\StripTags;
14
use Zend\Validator\NotEmpty;
15
16
class Text extends FieldAbstract
17
{
18
    /**
19
     * @return string
20
     */
21 5
    public function getTag()
22
    {
23 5
        return 'input';
24
    }
25
26
27 13
    public function init()
28
    {
29 13
        $this->setAttribute('type', 'text');
30 13
        $this->setAttribute('class', 'form-control');
31 13
        $stringTrim = new FilterAdapterZf(new StringTrim());
32 13
        $stripTags = new FilterAdapterZf(new StripTags());
33 13
        $notEmpty = new ValidatorAdapterZf(new NotEmpty());
34 13
        $this->addFilter($stringTrim)
35 13
            ->addFilter($stripTags)
36 13
            ->addValidator($notEmpty);
37 13
    }
38
39
    /**
40
     * @return string
41
     */
42 1
    public function getPlaceholder()
43
    {
44 1
        return $this->getAttribute('placeholder');
45
    }
46
47
    /**
48
     * @param string $placeholder
49
     */
50 1
    public function setPlaceholder($placeholder)
51
    {
52 1
        $this->setAttribute('placeholder', $placeholder);
53 1
    }
54
55
56
}