Textarea   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 16
c 1
b 0
f 0
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A RenderHtml() 0 12 2
A __construct() 0 8 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Iriven France
5
 * Date: 21/05/2018
6
 * Time: 08:04
7
 */
8
9
namespace Iriven\Plugins\Form\Elements;
10
11
12
class Textarea extends Text
13
{
14
    public function __construct($label, $attributes = [])
15
    {
16
        parent::__construct($label, $attributes);
17
        $this->Attributes()->set('type','textarea');
18
        $this->Attributes()->set('rows',$this->Attributes()->get('rows',6));
19
        $this->Attributes()->set('cols',$this->Attributes()->get('cols',60));
20
        $this->Attributes()->Ignore('value');
21
        $this->Label()->Attribute()->add(['style'=>'vertical-align: top;']);
22
    }
23
24
    /**
25
     * @return string
26
     */
27
    public function RenderHtml(): string
28
    {
29
        if (!$this->Attributes()->has('id'))
30
            $this->Attributes()->createElementID($this->Attributes()->get('name', $this->label()->getItemID()));
31
        $this->label()->Attribute()->set('fieldtype', $this->Attributes()->get('type'));
32
        $this->label()->Attribute()->set('for', $this->Attributes()->get('id'));
33
34
        $html  = $this->Label()->RenderHtml();
35
        $html .= '<textarea'. $this->Attributes()->RenderHtml().'>';
36
        $html .= $this->Attributes()->get('value','');
37
        $html .= '</textarea>';
38
        return $html;
39
    }
40
41
}