@@ -157,53 +157,33 @@ public function toString(): string
157157 */
158158 public function toArray ()
159159 {
160- try {
161- return json_decode ($ this ->toJson (), true , 512 , JSON_THROW_ON_ERROR );
162- } catch (\Throwable $ ex ) {
163- throw new \LogicException (
164- 'Unable to convert document to an array. See previous exception for cause of failure. ' ,
165- 0 ,
166- $ ex ,
167- );
168- }
160+ return json_decode (
161+ json: $ this ->toJson (),
162+ associative: true ,
163+ flags: JSON_THROW_ON_ERROR ,
164+ );
169165 }
170166
171167 /**
172168 * @inheritDoc
173169 */
174170 public function jsonSerialize (): array
175171 {
176- try {
177- $ this ->prepareEncoder ();
178-
179- return $ this ->serialize ();
180- } catch (\Throwable $ ex ) {
181- throw new \LogicException (
182- 'Unable to serialize compound document. See previous exception for cause of failure. ' ,
183- 0 ,
184- $ ex ,
185- );
186- }
172+ $ this ->prepareEncoder ();
173+
174+ return $ this ->serialize ();
187175 }
188176
189177 /**
190178 * @inheritDoc
191179 */
192180 public function toJson ($ options = 0 )
193181 {
194- try {
195- $ this ->prepareEncoder ();
196-
197- $ this ->encoder ->withEncodeOptions ($ options | JSON_THROW_ON_ERROR );
198-
199- return $ this ->encode ();
200- } catch (\Throwable $ ex ) {
201- throw new \LogicException (
202- 'Unable to encode compound document. See previous exception for cause of failure. ' ,
203- 0 ,
204- $ ex ,
205- );
206- }
182+ $ this ->prepareEncoder ();
183+
184+ $ this ->encoder ->withEncodeOptions ($ options | JSON_THROW_ON_ERROR );
185+
186+ return $ this ->encode ();
207187 }
208188
209189 /**
0 commit comments