11<?php
2+
23declare (strict_types=1 );
34
45namespace Webfox \InertiaDataProviders ;
56
7+ use Illuminate \Contracts \Support \Arrayable ;
68use Illuminate \Support \Arr ;
79use Illuminate \Support \Collection ;
8- use Illuminate \Contracts \Support \Arrayable ;
910
1011class DataProviderCollection implements Arrayable
1112{
@@ -20,8 +21,9 @@ public function __construct(DataProvider|array ...$dataProviders)
2021
2122 public function add (DataProvider |array ...$ dataProviders ): static
2223 {
23- $ this ->dataProviders = $ this ->dataProviders ->concat (collect ($ dataProviders )
24- ->map (fn (DataProvider |array $ dataProvider ) => Arr::wrap ($ dataProvider ))
24+ $ this ->dataProviders = $ this ->dataProviders ->concat (
25+ collect ($ dataProviders )
26+ ->map (fn (DataProvider |array $ dataProvider ) => Arr::wrap ($ dataProvider ))
2527 ->flatten ()
2628 ->filter ()
2729 );
@@ -34,7 +36,7 @@ public function add(DataProvider|array ...$dataProviders): static
3436 */
3537 public function remove (string $ dataProvider ): static
3638 {
37- $ this ->dataProviders = $ this ->dataProviders ->filter (fn (DataProvider $ instance ) => $ instance ::class !== $ dataProvider );
39+ $ this ->dataProviders = $ this ->dataProviders ->filter (fn (DataProvider $ instance ) => $ instance ::class !== $ dataProvider );
3840
3941 return $ this ;
4042 }
@@ -47,6 +49,7 @@ public function collection(): Collection
4749 public function empty (): static
4850 {
4951 $ this ->dataProviders = collect ();
52+
5053 return $ this ;
5154 }
5255
@@ -71,7 +74,7 @@ public function when(bool|callable $condition, callable $callback): static
7174 */
7275 public function unless (bool |callable $ condition , callable $ callback ): static
7376 {
74- if (!value ($ condition )) {
77+ if (! value ($ condition )) {
7578 $ callback ($ this );
7679 }
7780
@@ -81,7 +84,7 @@ public function unless(bool|callable $condition, callable $callback): static
8184 public function toArray (): array
8285 {
8386 return $ this ->dataProviders
84- ->flatMap (fn (DataProvider $ dataProvider ) => $ dataProvider ->toArray ())
87+ ->flatMap (fn (DataProvider $ dataProvider ) => $ dataProvider ->toArray ())
8588 ->all ();
8689 }
87- }
90+ }
0 commit comments