Hidden   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 44
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B create() 0 30 8
1
<?php
2
3
namespace Faulancer\Form\Type\Base;
4
5
use Faulancer\Form\Type\AbstractType;
6
7
/**
8
 * Class Hidden
9
 *
10
 * @package Faulancer\Form\Type\Base
11
 * @author Florian Knapp <[email protected]>
12
 */
13
class Hidden extends AbstractType
14
{
15
16
    /** @var string */
17
    protected $inputType = 'input';
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 (!empty($this->getValue()) && $attr === 'value') {
34
                continue;
35
            }
36
37
            if ($attr === 'name' && $value === 'csrf' && $this->getValue()) {
38
                continue;
39
            }
40
41
            $output .= ' ' . $attr . '="' . $value . '" ';
42
43
        }
44
45
        if (!empty($this->getValue())) {
46
            $output .= ' value="' . $this->getValue() . '"';
47
        }
48
49
        $output .= '/>';
50
51
        $this->element = $output;
52
53
        return $this;
54
    }
55
56
}