File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed
Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ protected function toArray($value): array
7676 ->map (fn ($ value ) => Instance::of ($ value , Carbon::class) ? $ value ->toIso8601String () : $ value )
7777 ->map (fn ($ value ) => Instance::of ($ value , FormRequest::class) ? $ value ->validated () : $ value )
7878 ->map (fn ($ value ) => Instance::of ($ value , BackedEnum::class) ? ($ value ->value ?? $ value ->name ) : $ value )
79+ ->map (fn ($ value ) => is_object ($ value ) ? (Arr::resolve ($ value ) ?: get_class ($ value )) : $ value )
7980 ->resolve ()
8081 ->toArray ();
8182 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Tests \Fixtures \Simple ;
6+
7+ class CustomObjectWithoutProperties
8+ {
9+ }
Original file line number Diff line number Diff line change 1515use Tests \Fixtures \Enums \WithValueEnum ;
1616use Tests \Fixtures \Models \User ;
1717use Tests \Fixtures \Simple \CustomObject ;
18+ use Tests \Fixtures \Simple \CustomObjectWithoutProperties ;
1819use Tests \TestCase ;
1920
2021class KeyTest extends TestCase
@@ -103,13 +104,13 @@ public function testArrayable()
103104 $ this ->assertSame ($ expected , $ key );
104105 }
105106
106- public function testCustomObject ()
107+ public function testCustomObjects ()
107108 {
108- $ key = Key::get (': ' , [new CustomObject ()]);
109+ $ key1 = Key::get (': ' , [new CustomObject ()]);
110+ $ key2 = Key::get (': ' , [new CustomObjectWithoutProperties ()]);
109111
110- $ expected = 'b58721335d52d66a9486072fe3383ccf ' ;
111-
112- $ this ->assertSame ($ expected , $ key );
112+ $ this ->assertSame ('b58721335d52d66a9486072fe3383ccf ' , $ key1 );
113+ $ this ->assertSame ('9be04f864d3649e49e892638361d5d49 ' , $ key2 );
113114 }
114115
115116 public function testMultiObjectArrays ()
You can’t perform that action at this time.
0 commit comments