FormLineP   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A setPostInitHook() 0 4 1
A init() 0 15 1
1
<?php
2
3
namespace hemio\form\template;
4
5
use hemio\html;
6
use hemio\form\Abstract_;
7
use hemio\html\Interface_\Submittable;
8
9
/**
10
 *
11
 *
12
 */
13
class FormLineP extends Abstract_\TemplateFormField
14
{
15
16
    public function __construct()
17
    {
18
        $this['P']          = new html\P;
19
        $this['P']['LABEL'] = new html\Label();
20
        $this->setPostInitHook(function ($template) {
0 ignored issues
show
Unused Code introduced by
The parameter $template is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
22
        });
23
    }
24
25
    public function setPostInitHook(callable $function)
26
    {
27
        $this->postInitHook = $function;
28
    }
29
30
    public function init(Abstract_\FormField $field, Submittable $control)
31
    {
32
        $this->setField($field);
33
        $this->setControl($control);
34
35
        $this['P']['LABEL']->addChild($field->getHtmlTitle());
36
        $this['P']['LABEL']->setAttribute('for', $this->field->getHtmlId());
37
38
        $control->setAttribute('name', $field->getHtmlName());
39
        $control->setId($field->getHtmlId());
40
        $this['P']['CONTROL'] = $control;
41
42
        $hook = $this->postInitHook;
43
        $hook($this);
44
    }
45
}
46