File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ function unslash(string $string): string
2828
2929namespace Hyde {
3030 use Hyde \Foundation \HydeKernel ;
31+ use Illuminate \Contracts \Support \Arrayable ;
3132
3233 if (! function_exists ('\Hyde\hyde ' )) {
3334 /**
@@ -76,4 +77,11 @@ function trim_slashes(string $string): string
7677 return hyde ()->trimSlashes ($ string );
7778 }
7879 }
80+
81+ if (! function_exists ('\Hyde\evaluate_arrayable ' )) {
82+ function evaluate_arrayable (array |Arrayable $ array ): array
83+ {
84+ return $ array instanceof Arrayable ? $ array ->toArray () : $ array ;
85+ }
86+ }
7987}
Original file line number Diff line number Diff line change @@ -105,4 +105,11 @@ public function test_hyde_trim_slashes_function()
105105 {
106106 $ this ->assertSame (Hyde::trimSlashes ('foo ' ), \Hyde \trim_slashes ('foo ' ));
107107 }
108+
109+ /** @covers ::\Hyde\evaluate_arrayable */
110+ public function test_hyde_evaluate_arrayable_function ()
111+ {
112+ $ this ->assertSame (['foo ' ], \Hyde \evaluate_arrayable (['foo ' ]));
113+ $ this ->assertSame (['foo ' ], \Hyde \evaluate_arrayable (collect (['foo ' ])));
114+ }
108115}
You can’t perform that action at this time.
0 commit comments