AbstractValidator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A isRequired() 0 4 1
A isNested() 0 4 1
A getErrorDescription() 0 4 1
A setErrorDescription() 0 4 1
A setParams() 0 6 2
isValid() 0 1 ?
1
<?php
2
3
/*
4
 *  @author Serkin Akexander <[email protected]>
5
 */
6
7
namespace Volan\Validator;
8
9
abstract class AbstractValidator
10
{
11
12
    /**
13
     * @var string Last Error description
14
     */
15
    protected $errorDescription = null;
16
17
    /**
18
     * @var array $params
19
     */
20
    protected $params = [];
21
22
    /**
23
     * @return bool
24
     */
25
    public function isRequired()
26
    {
27
        return false;
28
    }
29
30
    /**
31
     * @return bool
32
     */
33
    public function isNested()
34
    {
35
        return false;
36
    }
37
38
    /**
39
     * Gets error description
40
     *
41
     * @return mixed
42
     */
43
    public function getErrorDescription()
44
    {
45
        return $this->errorDescription;
46
    }
47
48
49
    /**
50
     * Sets error description
51
     *
52
     * @param string $error
53
     *
54
     */
55
    public function setErrorDescription($error)
56
    {
57
        $this->errorDescription = $error;
58
    }
59
60
    /*
61
     * Sets custom params
62
     *
63
     * @param array $arr
64
     *
65
     * @return void
66
     */
67
    public function setParams($arr = [])
68
    {
69
        foreach ($arr  as $key => $value) {
70
            $this->params[$key] = $value;
71
        }
72
    }
73
74
75
    /**
76
     *
77
     * @param mixed $nodeData
78
     *
79
     * @return bool
80
     */
81
    abstract public function isValid($nodeData);
82
}
83