Passed
Push — master ( 590085...649359 )
by
unknown
37s
created

Field::setValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: harry
5
 * Date: 2/16/18
6
 * Time: 11:01 PM
7
 */
8
9
namespace PluginSimpleValidate\BaseAbstract;
10
11
use PluginSimpleValidate\Contracts\BaseField;
12
use PluginSimpleValidate\Libraries\Language;
13
14
abstract class Field implements BaseField
15
{
16
    const VAR_LIMIT = 'limit';
17
18
    const VAR_MATCH = 'match';
19
20
    const VAR_LOWER_LIMIT = 'lower';
21
22
    const VAR_UPPER_LIMIT = 'upper';
23
24
    const VAR_MESSAGE = 'message';
25
26
    const VAR_REGION = 'region';
27
28
    /**
29
     * @var string
30
     */
31
    protected $name;
32
33
    /**
34
     * @var mixed
35
     */
36
    protected $value;
37
38
    /**
39
     * @var array
40
     */
41
    protected $errors;
42
43
    /**
44
     * @var array
45
     * array of Rule
46
     */
47
    protected $rules = [];
48
49
    /**
50
     * @var bool
51
     */
52
    protected $status;
53
54
    /**
55
     * @var \PluginSimpleValidate\Contracts\RuleMapping
56
     */
57
    protected $ruleMapping;
58
59
    /**
60
     * Field constructor.
61
     * @param string $name
62
     * @param mixed $value
63
     */
64 15
    public function __construct(
65
        string $name,
66
        $value
67
    ) {
68 15
        $this->name = $name;
69 15
        $this->value = $value;
70 15
        $this->errors = [];
71 15
    }
72
73
    /**
74
     * @return string
75
     */
76 5
    public function getName(): string
77
    {
78 5
        return $this->name;
79
    }
80
81
    /**
82
     * @return array
83
     */
84
    public function getRules(): array
85
    {
86
        return $this->rules;
87
    }
88
89
    /**
90
     * @return array
91
     */
92 12
    public function getErrors(): array
93
    {
94 12
        return $this->errors;
95
    }
96
97
    /**
98
     * @return $this
99
     */
100 13
    protected function emptyErrors()
101
    {
102 13
        $this->errors = [];
103 13
        return $this;
104
    }
105
}