1 | <?php |
||
11 | class Attribute |
||
12 | { |
||
13 | /** |
||
14 | * Name of property contains related object. |
||
15 | * Value is optional. Can be set only for real properties. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $propertyName; |
||
20 | |||
21 | /** |
||
22 | * Unique name of serialized attribute |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $name; |
||
27 | |||
28 | /** |
||
29 | * Data-type |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $type; |
||
34 | |||
35 | /** |
||
36 | * Attribute is an iterable container of values |
||
37 | * |
||
38 | * @var bool |
||
39 | */ |
||
40 | protected $many; |
||
41 | |||
42 | /** |
||
43 | * Parameters for data-type handler |
||
44 | * |
||
45 | * @var array |
||
46 | */ |
||
47 | protected $typeParameters = []; |
||
48 | |||
49 | /** |
||
50 | * Getter-method to access value |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $getter; |
||
55 | |||
56 | /** |
||
57 | * Setter-method to access value |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $setter; |
||
62 | |||
63 | /** |
||
64 | * Process null-values: |
||
65 | * - add to resource attribute with null-value |
||
66 | * - set to object null value from resources |
||
67 | * |
||
68 | * @var bool |
||
69 | */ |
||
70 | protected $processNull; |
||
71 | |||
72 | /** |
||
73 | * Attribute constructor. |
||
74 | * |
||
75 | * @param string $name |
||
76 | * @param string $getter |
||
77 | */ |
||
78 | 45 | public function __construct(string $name, string $getter) |
|
83 | |||
84 | /** |
||
85 | * Get name |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | 6 | public function getName(): string |
|
93 | |||
94 | /** |
||
95 | * Get name of getter-method to access value of attribute |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | 6 | public function getGetter(): string |
|
103 | |||
104 | /** |
||
105 | * Set name of setter-method to access value of attribute |
||
106 | * |
||
107 | * @param string $name |
||
108 | */ |
||
109 | 6 | public function setSetter(string $name) |
|
113 | |||
114 | /** |
||
115 | * Has setter-method defined ? |
||
116 | * |
||
117 | * @return bool |
||
118 | */ |
||
119 | 4 | public function hasSetter(): bool |
|
123 | |||
124 | /** |
||
125 | * Get name of setter-method to access value of attribute |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | 6 | public function getSetter(): string |
|
133 | |||
134 | /** |
||
135 | * Set flag "processNull" |
||
136 | * |
||
137 | * @param bool $process |
||
138 | */ |
||
139 | 4 | public function setProcessNull($process = true) |
|
143 | |||
144 | /** |
||
145 | * Get value of "processNull" flag |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | 4 | public function getProcessNull(): bool |
|
153 | |||
154 | /** |
||
155 | * Has flag "processNull" defined |
||
156 | * |
||
157 | * @return bool |
||
158 | */ |
||
159 | public function hasProcessNull(): bool |
||
163 | |||
164 | /** |
||
165 | * Set name of data-type |
||
166 | * |
||
167 | * @param string $type |
||
168 | */ |
||
169 | 34 | public function setType(string $type) |
|
173 | |||
174 | /** |
||
175 | * Has data-type defined ? |
||
176 | * |
||
177 | * @return bool |
||
178 | */ |
||
179 | 1 | public function hasType(): bool |
|
183 | |||
184 | /** |
||
185 | * Get name of data-type |
||
186 | * |
||
187 | * @return string |
||
188 | */ |
||
189 | 35 | public function getType(): string |
|
193 | |||
194 | /** |
||
195 | * Set "many" flag |
||
196 | * |
||
197 | * @param bool $many |
||
198 | */ |
||
199 | 12 | public function setMany($many = true) |
|
203 | |||
204 | /** |
||
205 | * Attribute is an iterable container of values ? |
||
206 | * |
||
207 | * @return bool |
||
208 | */ |
||
209 | 33 | public function isMany(): bool |
|
213 | |||
214 | /** |
||
215 | * Flag "many" has been defined |
||
216 | * |
||
217 | * @return bool |
||
218 | */ |
||
219 | public function hasManyDefined(): bool |
||
223 | |||
224 | /** |
||
225 | * Set parameters of data-type handling |
||
226 | * |
||
227 | * @param array $parameters |
||
228 | */ |
||
229 | 13 | public function setTypeParameters(array $parameters) |
|
233 | |||
234 | /** |
||
235 | * Get parameters of data-type handling |
||
236 | * |
||
237 | * @return array |
||
238 | */ |
||
239 | 34 | public function getTypeParameters(): array |
|
243 | |||
244 | /** |
||
245 | * Set name of property contains related object |
||
246 | * |
||
247 | * @param string $name |
||
248 | */ |
||
249 | 19 | public function setPropertyName(string $name) |
|
253 | |||
254 | /** |
||
255 | * Has name of property ? |
||
256 | * |
||
257 | * @return bool |
||
258 | */ |
||
259 | 3 | public function hasPropertyName(): bool |
|
263 | |||
264 | /** |
||
265 | * Get name of property contains related object |
||
266 | * |
||
267 | * @return string |
||
268 | */ |
||
269 | 4 | public function getPropertyName(): string |
|
273 | |||
274 | /** |
||
275 | * Merge a attribute into this one |
||
276 | * |
||
277 | * @param self $attribute |
||
278 | */ |
||
279 | 1 | public function merge(self $attribute) |
|
301 | } |