GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DataField::validators()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace Solvire\API\Serializers\DataFields;
3
4
/**
5
 *
6
 * @author solvire <[email protected]>
7
 * @package DataFields
8
 * @namespace Solvire\API\Serializers\DataFields
9
 */
10
abstract class DataField
11
{
12
13
    /**
14
     * holder for the data linked to this object
15
     *
16
     * @var mixed
17
     */
18
    protected $data = null;
19
20
    protected $name = null;
21
22
    protected $columnName = null;
23
24
    protected $readOnly = false;
25
26
    protected $writeOnly = false;
27
28
    protected $required = false;
29
30
    protected $allowNull = false;
31
    
32
    protected $allowEmpty = false;
33
34
    protected $defaultValue = null;
35
36
    protected $initial = null;
37
38
    protected $label = null;
39
40
    protected $helpText = null;
41
42
    protected $style = null;
43
44
    protected $errorMessages = null;
45
46
    protected $validators = null;
47
48
    protected $requiredFields = [];
49
50
    protected $cast = null;
51
52
    protected $castTypes = [
53
        'string',
54
        'integer',
55
        'datetime',
56
        'time',
57
        'object'
58
    ];
59
60
    protected $fillable = [
61
        'name',
62
        'columnName',
63
        'readOnly',
64
        'writeOnly',
65
        'required',
66
        'allowNull',
67
        'allowEmpty',
68
        'defaultValue',
69
        'initial',
70
        'label',
71
        'helpText',
72
        'style',
73
        'validators'
74
    ];
75
76
    /**
77
     *
78
     * @param array $options            
79
     */
80 39
    public function __construct(array $options = [])
81
    {
82 39
        $this->loadOptions($options);
83 39
    }
84
85
    /**
86
     *
87
     * @param array $options            
88
     */
89 39
    protected function loadOptions($options)
90
    {
91 39
        foreach ($this->fillable as $key) {
92 39
            if (isset($options[$key]))
93 39
                $this->$key = $options[$key];
94 39
        }
95 39
    }
96
97 10
    public function setName($name)
98
    {
99 10
        $this->name = $name;
100 10
        return $this;
101
    }
102
103 2
    public function getName()
104
    {
105 2
        return $this->name;
106
    }
107
108
    abstract public function setData($data);
109
110
    /**
111
     * returns the data in the most usable format
112
     */
113
    abstract public function getData();
114
115
    /**
116
     * returns the data in a format that is probably most storable
117
     */
118 1
    public function getRaw()
119
    {
120 1
        return $this->data;
121
    }
122
123 2
    public function columnName()
124
    {
125 2
        return $this->columnName;
126
    }
127
128 1
    public function readOnly()
129
    {
130 1
        return (boolean) $this->readOnly;
131
    }
132
133 2
    public function writeOnly()
134
    {
135 2
        return (boolean) $this->writeOnly;
136
    }
137
138 1
    public function required()
139
    {
140 1
        return (boolean) $this->required;
141
    }
142
143 3
    public function allowNull()
144
    {
145 3
        return (boolean) $this->allowNull;
146
    }
147
    
148 1
    public function allowEmpty()
149
    {
150 1
        return (boolean) $this->allowEmpty;
151
    }
152
153 1
    public function defaultValue()
154
    {
155 1
        return $this->defaultValue;
156
    }
157
158 1
    public function initial()
159
    {
160 1
        return $this->initial;
161
    }
162
163 1
    public function label()
164
    {
165 1
        return $this->label;
166
    }
167
168 1
    public function helpText()
169
    {
170 1
        return $this->helpText;
171
    }
172
173 1
    public function style()
174
    {
175 1
        return $this->style;
176
    }
177
178 1
    public function setErrorMessages($messages)
179
    {
180 1
        if (! is_array($messages))
181 1
            throw new \RuntimeExcpeiotn("The eerror message should be ot type array.");
182 1
        $this->errorMessages = $messages;
183 1
    }
184
185 1
    public function getErrorMessages()
186
    {
187 1
        return $this->errorMessages;
188
    }
189
190 1
    public function validators()
191
    {
192 1
        return $this->validators;
193
    }
194
}