@@ -87,16 +87,15 @@ public function __construct(
87
87
array $ source = null ,
88
88
$ meta = null
89
89
) {
90
- assert ($ idx === null || is_int ($ idx ) === true || is_string ($ idx ) === true );
91
-
92
- $ this ->idx = $ idx ;
93
- $ this ->links = ($ aboutLink === null ? null : [DocumentInterface::KEYWORD_ERRORS_ABOUT => $ aboutLink ]);
94
- $ this ->status = ($ status !== null ? (string )$ status : null );
95
- $ this ->code = ($ code !== null ? (string )$ code : null );
96
- $ this ->title = $ title ;
97
- $ this ->source = $ source ;
98
- $ this ->detail = $ detail ;
99
- $ this ->meta = $ meta ;
90
+ $ this
91
+ ->setId ($ idx )
92
+ ->setLink (DocumentInterface::KEYWORD_ERRORS_ABOUT , $ aboutLink )
93
+ ->setStatus ($ status )
94
+ ->setCode ($ code )
95
+ ->setTitle ($ title )
96
+ ->setDetail ($ detail )
97
+ ->setSource ($ source )
98
+ ->setMeta ($ meta );
100
99
}
101
100
102
101
/**
@@ -107,6 +106,20 @@ public function getId()
107
106
return $ this ->idx ;
108
107
}
109
108
109
+ /**
110
+ * @param string|int|null $idx
111
+ *
112
+ * @return self
113
+ */
114
+ public function setId ($ idx ): self
115
+ {
116
+ assert ($ idx === null || is_int ($ idx ) === true || is_string ($ idx ) === true );
117
+
118
+ $ this ->idx = $ idx ;
119
+
120
+ return $ this ;
121
+ }
122
+
110
123
/**
111
124
* @inheritdoc
112
125
*/
@@ -115,6 +128,23 @@ public function getLinks(): ?array
115
128
return $ this ->links ;
116
129
}
117
130
131
+ /**
132
+ * @param string $name
133
+ * @param LinkInterface|null $link
134
+ *
135
+ * @return self
136
+ */
137
+ public function setLink (string $ name , ?LinkInterface $ link ): self
138
+ {
139
+ if ($ link !== null ) {
140
+ $ this ->links [$ name ] = $ link ;
141
+ } else {
142
+ unset($ this ->links [$ name ]);
143
+ }
144
+
145
+ return $ this ;
146
+ }
147
+
118
148
/**
119
149
* @inheritdoc
120
150
*/
@@ -123,6 +153,18 @@ public function getStatus(): ?string
123
153
return $ this ->status ;
124
154
}
125
155
156
+ /**
157
+ * @param string|null $status
158
+ *
159
+ * @return self
160
+ */
161
+ public function setStatus (?string $ status ): self
162
+ {
163
+ $ this ->status = $ status ;
164
+
165
+ return $ this ;
166
+ }
167
+
126
168
/**
127
169
* @inheritdoc
128
170
*/
@@ -131,6 +173,18 @@ public function getCode(): ?string
131
173
return $ this ->code ;
132
174
}
133
175
176
+ /**
177
+ * @param string|null $code
178
+ *
179
+ * @return self
180
+ */
181
+ public function setCode (?string $ code ): self
182
+ {
183
+ $ this ->code = $ code ;
184
+
185
+ return $ this ;
186
+ }
187
+
134
188
/**
135
189
* @inheritdoc
136
190
*/
@@ -139,6 +193,18 @@ public function getTitle(): ?string
139
193
return $ this ->title ;
140
194
}
141
195
196
+ /**
197
+ * @param null|string $title
198
+ *
199
+ * @return self
200
+ */
201
+ public function setTitle (?string $ title ): self
202
+ {
203
+ $ this ->title = $ title ;
204
+
205
+ return $ this ;
206
+ }
207
+
142
208
/**
143
209
* @inheritdoc
144
210
*/
@@ -147,6 +213,18 @@ public function getDetail(): ?string
147
213
return $ this ->detail ;
148
214
}
149
215
216
+ /**
217
+ * @param null|string $detail
218
+ *
219
+ * @return self
220
+ */
221
+ public function setDetail (?string $ detail ): self
222
+ {
223
+ $ this ->detail = $ detail ;
224
+
225
+ return $ this ;
226
+ }
227
+
150
228
/**
151
229
* @inheritdoc
152
230
*/
@@ -155,11 +233,35 @@ public function getSource(): ?array
155
233
return $ this ->source ;
156
234
}
157
235
236
+ /**
237
+ * @param array|null $source
238
+ *
239
+ * @return self
240
+ */
241
+ public function setSource (?array $ source ): self
242
+ {
243
+ $ this ->source = $ source ;
244
+
245
+ return $ this ;
246
+ }
247
+
158
248
/**
159
249
* @inheritdoc
160
250
*/
161
251
public function getMeta ()
162
252
{
163
253
return $ this ->meta ;
164
254
}
255
+
256
+ /**
257
+ * @param mixed|null $meta
258
+ *
259
+ * @return self
260
+ */
261
+ public function setMeta ($ meta ): self
262
+ {
263
+ $ this ->meta = $ meta ;
264
+
265
+ return $ this ;
266
+ }
165
267
}
0 commit comments