CheckableOption::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 4
1
<?php
2
3
class CheckableOption extends CompositeField
4
{
5
    protected $childField, $checkbox;
6
7
    public function __construct($checkName, $childField, $value = "", $readonly = false)
8
    {
9
        $this->name = $checkName;
10
        $this->checkbox = new CheckboxField($checkName, "", $value);
11
        if ($readonly) {
12
            $this->checkbox->setDisabled(true);
13
        }
14
15
        $this->childField = $childField;
16
17
        $children = new FieldList(
18
            $this->childField,
19
            $this->checkbox
20
        );
21
22
        parent::__construct($children);
23
    }
24
25
    public function FieldHolder($properties = array())
26
    {
27
        return FormField::FieldHolder($properties);
28
    }
29
30
    public function Message()
31
    {
32
        return $this->childField->Message();
33
    }
34
35
    public function MessageType()
36
    {
37
        return $this->childField->MessageType();
38
    }
39
40
    public function Title()
41
    {
42
        return $this->childField->Title();
43
    }
44
45
    public function Field($properties = array())
46
    {
47
        return $this->childField->Field() . ' ' . $this->checkbox->Field();
48
    }
49
}
50