TextArea   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 51
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B create() 0 37 7
1
<?php
2
3
namespace Faulancer\Form\Type\Base;
4
5
use Faulancer\Form\Type\AbstractType;
6
7
/**
8
 * Class TextArea
9
 *
10
 * @package Faulancer\Form\Type\Base
11
 * @author  Florian Knapp <[email protected]>
12
 */
13
class TextArea extends AbstractType
14
{
15
16
    /** @var string */
17
    protected $inputType = 'textarea';
18
19
    /** @var string */
20
    protected $element = '';
21
22
    /**
23
     * @return self
24
     */
25
    public function create()
26
    {
27
        parent::create();
28
29
        $output = '<' . $this->inputType . ' ';
30
31
        foreach ($this->definition['attributes'] as $attr => $value) {
32
33
            if ($attr === 'value') { // There is no value attribute for textarea fields
34
                continue;
35
            }
36
37
            if ($attr === 'name' && !empty($this->getName())) {
38
                continue;
39
            }
40
41
            $output .= $attr . '="' . $value . '" ';
42
43
        }
44
45
        if (!empty($this->getName())) {
46
            $output .= ' name="' . $this->getName() . '"';
47
        }
48
49
        $output .= '>';
50
51
        if (!empty($this->getValue())) {
52
            $output .= $this->getValue();
53
        }
54
55
        $output .= '</textarea>';
56
57
        $this->element = $output;
58
59
        return $this;
60
61
    }
62
63
}