1414
1515trait TransformableData
1616{
17+ /**
18+ * Transform the data object into an array.
19+ *
20+ * @param null|TransformationContextFactory|TransformationContext $transformationContext
21+ * @return array<string, mixed>
22+ */
1723 public function transform (
1824 null |TransformationContextFactory |TransformationContext $ transformationContext = null ,
1925 ): array {
@@ -39,11 +45,21 @@ public function transform(
3945 return $ resolver ->execute ($ this , $ transformationContext );
4046 }
4147
48+ /**
49+ * Get all data as an array without transforming values.
50+ *
51+ * @return array<string, mixed>
52+ */
4253 public function all (): array
4354 {
4455 return $ this ->transform (TransformationContextFactory::create ()->withValueTransformation (false ));
4556 }
4657
58+ /**
59+ * Get the data object as an array.
60+ *
61+ * @return array<string, mixed>
62+ */
4763 public function toArray (): array
4864 {
4965 return $ this ->transform ();
@@ -54,6 +70,11 @@ public function toJson($options = 0): string
5470 return json_encode ($ this ->transform (), $ options );
5571 }
5672
73+ /**
74+ * Get the data object as an array for JSON serialization.
75+ *
76+ * @return array<string, mixed>
77+ */
5778 public function jsonSerialize (): array
5879 {
5980 return $ this ->transform ();
0 commit comments