@@ -87,16 +87,15 @@ public function __construct(
8787 array $ source = null ,
8888 $ meta = null
8989 ) {
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 );
10099 }
101100
102101 /**
@@ -107,6 +106,20 @@ public function getId()
107106 return $ this ->idx ;
108107 }
109108
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+
110123 /**
111124 * @inheritdoc
112125 */
@@ -115,6 +128,23 @@ public function getLinks(): ?array
115128 return $ this ->links ;
116129 }
117130
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+
118148 /**
119149 * @inheritdoc
120150 */
@@ -123,6 +153,18 @@ public function getStatus(): ?string
123153 return $ this ->status ;
124154 }
125155
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+
126168 /**
127169 * @inheritdoc
128170 */
@@ -131,6 +173,18 @@ public function getCode(): ?string
131173 return $ this ->code ;
132174 }
133175
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+
134188 /**
135189 * @inheritdoc
136190 */
@@ -139,6 +193,18 @@ public function getTitle(): ?string
139193 return $ this ->title ;
140194 }
141195
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+
142208 /**
143209 * @inheritdoc
144210 */
@@ -147,6 +213,18 @@ public function getDetail(): ?string
147213 return $ this ->detail ;
148214 }
149215
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+
150228 /**
151229 * @inheritdoc
152230 */
@@ -155,11 +233,35 @@ public function getSource(): ?array
155233 return $ this ->source ;
156234 }
157235
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+
158248 /**
159249 * @inheritdoc
160250 */
161251 public function getMeta ()
162252 {
163253 return $ this ->meta ;
164254 }
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+ }
165267}
0 commit comments