CheckboxFieldValidator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 29
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getJsonData() 0 6 1
A isValid() 0 4 1
A describeObject() 0 4 1
1
<?php
2
3
namespace fieldwork\validators;
4
5
class CheckboxFieldValidator extends FieldValidator
6
{
7
8
    private $checked;
9
10
    public function __construct ($checked, $errorMsg)
11
    {
12
        parent::__construct($errorMsg);
13
        $this->checked = $checked;
14
    }
15
16
    public function getJsonData ()
17
    {
18
        return array_merge(parent::getJsonData(), array(
19
            'checked' => $this->checked
20
        ));
21
    }
22
23
    public function isValid ($value)
24
    {
25
        return $this->checked === ($value === 'on');
26
    }
27
28
    public function describeObject ()
29
    {
30
        return 'checkbox';
31
    }
32
33
}
34