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
156
156
throw new SerializeException ($ e ->getMessage (), $ e ->getCode (), $ e );
157
157
}
158
158
}
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
+ }
159
172
}
Original file line number Diff line number Diff line change @@ -21,6 +21,20 @@ public static function create(mixed ...$args): static;
21
21
*/
22
22
public function jsonSerialize (): array ;
23
23
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
+
24
38
/**
25
39
* @throws DeserializeException
26
40
*/
Original file line number Diff line number Diff line change 6
6
use Nuxtifyts \PhpDto \Contracts \EmptyData as EmptyDataContract ;
7
7
use Nuxtifyts \PhpDto \Concerns \BaseData ;
8
8
use Nuxtifyts \PhpDto \Concerns \EmptyData ;
9
- use Nuxtifyts \PhpDto \Exceptions \SerializeException ;
10
9
11
10
abstract readonly class Data implements
12
11
BaseDataContract,
13
12
EmptyDataContract
14
13
{
15
14
use BaseData;
16
15
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
- }
32
16
}
You can’t perform that action at this time.
0 commit comments