File tree Expand file tree Collapse file tree 3 files changed +27
-16
lines changed Expand file tree Collapse file tree 3 files changed +27
-16
lines changed Original file line number Diff line number Diff line change @@ -156,4 +156,17 @@ final public function jsonSerialize(): array
156156 throw new SerializeException ($ e ->getMessage (), $ e ->getCode (), $ e );
157157 }
158158 }
159+
160+ /**
161+ * @throws SerializeException
162+ */
163+ final public function toArray (): array
164+ {
165+ return $ this ->jsonSerialize ();
166+ }
167+
168+ final public function toJson (): false |string
169+ {
170+ return json_encode ($ this );
171+ }
159172}
Original file line number Diff line number Diff line change @@ -21,6 +21,20 @@ public static function create(mixed ...$args): static;
2121 */
2222 public function jsonSerialize (): array ;
2323
24+ /**
25+ * @return array<string, mixed>
26+ *
27+ * @throws SerializeException
28+ */
29+ public function toArray (): array ;
30+
31+ /**
32+ * @return false|string
33+ *
34+ * @throws SerializeException
35+ */
36+ public function toJson (): false |string ;
37+
2438 /**
2539 * @throws DeserializeException
2640 */
Original file line number Diff line number Diff line change 66use Nuxtifyts \PhpDto \Contracts \EmptyData as EmptyDataContract ;
77use Nuxtifyts \PhpDto \Concerns \BaseData ;
88use Nuxtifyts \PhpDto \Concerns \EmptyData ;
9- use Nuxtifyts \PhpDto \Exceptions \SerializeException ;
109
1110abstract readonly class Data implements
1211 BaseDataContract,
1312 EmptyDataContract
1413{
1514 use BaseData;
1615 use EmptyData;
17-
18- /**
19- * @return array<string, mixed>
20- *
21- * @throws SerializeException
22- */
23- final public function toArray (): array
24- {
25- return $ this ->jsonSerialize ();
26- }
27-
28- final public function toJson (): false |string
29- {
30- return json_encode ($ this );
31- }
3216}
You can’t perform that action at this time.
0 commit comments