FieldValidator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getJsonData() 0 7 1
A setField() 0 4 1
A getField() 0 4 1
A getErrorMsg() 0 4 1
isValid() 0 1 ?
A skipValidation() 0 4 1
1
<?php
2
3
namespace fieldwork\validators;
4
5
use fieldwork\Synchronizable;
6
7
abstract class FieldValidator implements Synchronizable
8
{
9
10
    private $errorMsg = '', $field;
11
12
    public function __construct ($errorMsg)
13
    {
14
        $this->errorMsg = $errorMsg;
15
    }
16
17
    public function getJsonData ()
18
    {
19
        return array(
20
            'error'  => $this->errorMsg,
21
            'method' => $this->describeObject()
22
        );
23
    }
24
25
    public function setField ($f)
26
    {
27
        $this->field = $f;
28
    }
29
30
    public function getField ()
31
    {
32
        return $this->field;
33
    }
34
35
    public function getErrorMsg ()
36
    {
37
        return $this->errorMsg;
38
    }
39
40
    public abstract function isValid ($value);
41
42
    /**
43
     * Whether to skip the remaining field validators
44
     *
45
     * @param string $value
46
     *
47
     * @return bool
48
     */
49
    public function skipValidation ($value)
50
    {
51
        return false;
52
    }
53
54
}