/
MetadataField.php
206 lines (182 loc) · 3.97 KB
/
MetadataField.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php
/**
* This file is part of the Cloudinary PHP package.
*
* (c) Cloudinary
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cloudinary\Api\Metadata;
use Cloudinary\Api\Metadata\Validators\MetadataValidation;
/**
* Represents a single metadata field. Use one of the derived classes in metadata API calls.
*
* @api
*/
abstract class MetadataField extends Metadata
{
/**
* @var string
*/
protected $externalId;
/**
* @var string
*/
protected $label;
/**
* @var bool
*/
protected $mandatory;
/**
* @var mixed
*/
protected $defaultValue;
/**
* @var string
*/
protected $type;
/**
* @var MetadataValidation
*/
protected $validation;
/**
* @var array
*/
protected $restrictions;
/**
* The MetadataField constructor.
*
* @param string $label
*/
public function __construct($label)
{
$this->label = $label;
}
/**
* Gets the keys for all the properties of this object.
*
* @return string[]
*/
public function getPropertyKeys()
{
return ['externalId', 'label', 'mandatory', 'defaultValue', 'type', 'validation', 'restrictions'];
}
/**
* Returns the type of this field.
*
* @return string The type name.
*/
public function getType()
{
return $this->type;
}
/**
* Gets the default value of this field.
*
* @return mixed
*/
public function getDefaultValue()
{
return $this->defaultValue;
}
/**
* Sets the default value of this field.
*
* @param mixed $defaultValue
*/
public function setDefaultValue($defaultValue)
{
$this->defaultValue = $defaultValue;
}
/**
* Gets the ID of this field.
*
* @return string The field ID.
*/
public function getExternalId()
{
return $this->externalId;
}
/**
* Sets the ID of the string (auto-generated if this is left blank).
*
* @param string $externalId The ID to set.
*/
public function setExternalId($externalId)
{
$this->externalId = $externalId;
}
/**
* Gets the label of this field.
*
* @return string The label of the field.
*/
public function getLabel()
{
return $this->label;
}
/**
* Sets the label of this field.
*
* @param string $label The label to set.
*/
public function setLabel($label)
{
$this->label = $label;
}
/**
* Gets a boolean indicating whether this fields is currently mandatory.
*
* @return bool A boolean indicating whether the field is mandatory.
*/
public function getMandatory()
{
return $this->mandatory;
}
/**
* Sets whether this field needs to be mandatory.
*
* @param bool $mandatory A boolean indicating whether the field should be mandatory.
*/
public function setMandatory($mandatory)
{
$this->mandatory = $mandatory;
}
/**
* Gets the validation rules of this field.
*
* @return MetadataValidation The validation rules.
*/
public function getValidation()
{
return $this->validation;
}
/**
* Sets the validation rules of this field.
*
* @param MetadataValidation $validation The rules to set.
*/
public function setValidation(MetadataValidation $validation)
{
$this->validation = $validation;
}
/**
* Gets the restrictions of this field.
*
* @return array
*/
public function getRestrictions()
{
return $this->restrictions;
}
/**
* Sets the restrictions of this field.
*
* @param array $restrictions
*/
public function setRestrictions($restrictions)
{
$this->restrictions = $restrictions;
}
}