From 8cddaf6c155085de893d7455380aa6dbb5047580 Mon Sep 17 00:00:00 2001 From: Krishan Koenig Date: Tue, 10 Dec 2024 14:42:43 +0100 Subject: [PATCH] wip --- src/Contracts/DataProvider.php | 11 ----------- src/Factories/Factory.php | 7 ++----- src/Http/Payload/Address.php | 6 +++--- src/Http/Payload/AnyPayload.php | 2 +- src/Http/Payload/ApplicationFee.php | 2 +- src/Http/Payload/CreateClientLinkPayload.php | 2 +- src/Http/Payload/CreateCustomerPayload.php | 2 +- src/Http/Payload/CreateMandatePayload.php | 2 +- src/Http/Payload/CreatePaymentCapturePayload.php | 2 +- src/Http/Payload/CreatePaymentLinkPayload.php | 2 +- src/Http/Payload/CreatePaymentPayload.php | 2 +- src/Http/Payload/CreateProfilePayload.php | 2 +- src/Http/Payload/CreateRefundPaymentPayload.php | 2 +- src/Http/Payload/CreateSalesInvoicePayload.php | 2 +- src/Http/Payload/CreateSubscriptionPayload.php | 2 +- src/Http/Payload/DataBag.php | 8 +------- src/Http/Payload/DataCollection.php | 12 +----------- src/Http/Payload/Discount.php | 6 +++--- src/Http/Payload/EmailDetails.php | 6 +++--- src/Http/Payload/InvoiceLine.php | 2 +- src/Http/Payload/Metadata.php | 6 +++--- src/Http/Payload/Money.php | 6 +++--- src/Http/Payload/OrderLine.php | 2 +- src/Http/Payload/Owner.php | 6 +++--- src/Http/Payload/OwnerAddress.php | 6 +++--- src/Http/Payload/PaymentDetails.php | 6 +++--- src/Http/Payload/PaymentRoute.php | 2 +- src/Http/Payload/Recipient.php | 6 +++--- src/Http/Payload/RecurringBillingCycle.php | 2 +- src/Http/Payload/RefundRoute.php | 2 +- .../Payload/RequestApplePayPaymentSessionPayload.php | 2 +- src/Http/Payload/UpdatePaymentLinkPayload.php | 2 +- src/Http/Payload/UpdatePaymentPayload.php | 2 +- src/Http/Payload/UpdatePaymentRoutePayload.php | 2 +- src/Http/Payload/UpdateProfilePayload.php | 2 +- src/Http/Payload/UpdateSalesInvoicePayload.php | 2 +- src/Http/Payload/UpdateSubscriptionPayload.php | 2 +- src/Http/Requests/CreateClientLinkRequest.php | 2 +- src/Traits/ResolvesValues.php | 11 ++++++++--- tests/Traits/ResolvesValuesTest.php | 7 +++---- 40 files changed, 67 insertions(+), 93 deletions(-) delete mode 100644 src/Contracts/DataProvider.php diff --git a/src/Contracts/DataProvider.php b/src/Contracts/DataProvider.php deleted file mode 100644 index ae50396d..00000000 --- a/src/Contracts/DataProvider.php +++ /dev/null @@ -1,11 +0,0 @@ -data = $data->toArray(); - } elseif ($data instanceof DataProvider) { - $this->data = $data->data(); } else { $this->data = $data; } @@ -40,7 +37,7 @@ protected function get($key, $default = null, $backupKey = 'filters.') $keys = (array) $key; if ($backupKey !== null) { - $keys[] = $backupKey.$key; + $keys[] = $backupKey . $key; } foreach ($keys as $key) { @@ -63,7 +60,7 @@ protected function has($keys): bool */ protected function includes($key, $value, $backupKey = 'filters.'): bool { - return Arr::includes($this->data, [$backupKey.$key, $key], $value); + return Arr::includes($this->data, [$backupKey . $key, $key], $value); } /** diff --git a/src/Http/Payload/Address.php b/src/Http/Payload/Address.php index 5b48cb3a..caf389aa 100644 --- a/src/Http/Payload/Address.php +++ b/src/Http/Payload/Address.php @@ -2,10 +2,10 @@ namespace Mollie\Api\Http\Payload; -use Mollie\Api\Contracts\DataProvider; +use Mollie\Api\Contracts\Arrayable; use Mollie\Api\Traits\ComposableFromArray; -class Address implements DataProvider +class Address implements Arrayable { use ComposableFromArray; @@ -61,7 +61,7 @@ public function __construct( $this->country = $country; } - public function data(): array + public function toArray(): array { return [ 'title' => $this->title, diff --git a/src/Http/Payload/AnyPayload.php b/src/Http/Payload/AnyPayload.php index 7fc8cb5f..0c4babb4 100644 --- a/src/Http/Payload/AnyPayload.php +++ b/src/Http/Payload/AnyPayload.php @@ -15,7 +15,7 @@ public function __construct(?array $data = []) $this->data = $data; } - public function data(): array + public function toArray(): array { return $this->data ?? []; } diff --git a/src/Http/Payload/ApplicationFee.php b/src/Http/Payload/ApplicationFee.php index e2bf0b55..b300c3d7 100644 --- a/src/Http/Payload/ApplicationFee.php +++ b/src/Http/Payload/ApplicationFee.php @@ -16,7 +16,7 @@ public function __construct( $this->description = $description; } - public function data(): array + public function toArray(): array { return [ 'amount' => $this->amount, diff --git a/src/Http/Payload/CreateClientLinkPayload.php b/src/Http/Payload/CreateClientLinkPayload.php index eb47645f..a9725826 100644 --- a/src/Http/Payload/CreateClientLinkPayload.php +++ b/src/Http/Payload/CreateClientLinkPayload.php @@ -28,7 +28,7 @@ public function __construct( $this->vatNumber = $vatNumber; } - public function data(): array + public function toArray(): array { return [ 'owner' => $this->owner, diff --git a/src/Http/Payload/CreateCustomerPayload.php b/src/Http/Payload/CreateCustomerPayload.php index 33014985..086b2c79 100644 --- a/src/Http/Payload/CreateCustomerPayload.php +++ b/src/Http/Payload/CreateCustomerPayload.php @@ -24,7 +24,7 @@ public function __construct( $this->metadata = $metadata; } - public function data() + public function toArray(): array { return [ 'name' => $this->name, diff --git a/src/Http/Payload/CreateMandatePayload.php b/src/Http/Payload/CreateMandatePayload.php index db799c11..b9516dee 100644 --- a/src/Http/Payload/CreateMandatePayload.php +++ b/src/Http/Payload/CreateMandatePayload.php @@ -42,7 +42,7 @@ public function __construct( $this->paypalBillingAgreementId = $paypalBillingAgreementId; } - public function data(): array + public function toArray(): array { return [ 'method' => $this->method, diff --git a/src/Http/Payload/CreatePaymentCapturePayload.php b/src/Http/Payload/CreatePaymentCapturePayload.php index dfd5339c..d4ee7608 100644 --- a/src/Http/Payload/CreatePaymentCapturePayload.php +++ b/src/Http/Payload/CreatePaymentCapturePayload.php @@ -20,7 +20,7 @@ public function __construct( $this->metadata = $metadata; } - public function data(): array + public function toArray(): array { return [ 'description' => $this->description, diff --git a/src/Http/Payload/CreatePaymentLinkPayload.php b/src/Http/Payload/CreatePaymentLinkPayload.php index a66c62cf..9d7c0cab 100644 --- a/src/Http/Payload/CreatePaymentLinkPayload.php +++ b/src/Http/Payload/CreatePaymentLinkPayload.php @@ -38,7 +38,7 @@ public function __construct( $this->expiresAt = $expiresAt; } - public function data(): array + public function toArray(): array { return [ 'description' => $this->description, diff --git a/src/Http/Payload/CreatePaymentPayload.php b/src/Http/Payload/CreatePaymentPayload.php index fbcd681a..d1a85758 100644 --- a/src/Http/Payload/CreatePaymentPayload.php +++ b/src/Http/Payload/CreatePaymentPayload.php @@ -107,7 +107,7 @@ public function __construct( $this->additional = $additional; } - public function data(): array + public function toArray(): array { return array_merge([ 'description' => $this->description, diff --git a/src/Http/Payload/CreateProfilePayload.php b/src/Http/Payload/CreateProfilePayload.php index 2c865fe4..95e0a1dd 100644 --- a/src/Http/Payload/CreateProfilePayload.php +++ b/src/Http/Payload/CreateProfilePayload.php @@ -36,7 +36,7 @@ public function __construct( $this->businessCategory = $businessCategory; } - public function data(): array + public function toArray(): array { return [ 'name' => $this->name, diff --git a/src/Http/Payload/CreateRefundPaymentPayload.php b/src/Http/Payload/CreateRefundPaymentPayload.php index add71a44..3da56777 100644 --- a/src/Http/Payload/CreateRefundPaymentPayload.php +++ b/src/Http/Payload/CreateRefundPaymentPayload.php @@ -35,7 +35,7 @@ public function __construct( $this->routingReversals = $routingReversals; } - public function data(): array + public function toArray(): array { return [ 'description' => $this->description, diff --git a/src/Http/Payload/CreateSalesInvoicePayload.php b/src/Http/Payload/CreateSalesInvoicePayload.php index 362ebb91..208987a3 100644 --- a/src/Http/Payload/CreateSalesInvoicePayload.php +++ b/src/Http/Payload/CreateSalesInvoicePayload.php @@ -71,7 +71,7 @@ public function __construct( $this->discount = $discount; } - public function data(): array + public function toArray(): array { return [ 'profileId' => $this->profileId, diff --git a/src/Http/Payload/CreateSubscriptionPayload.php b/src/Http/Payload/CreateSubscriptionPayload.php index 49769e41..cd60de8d 100644 --- a/src/Http/Payload/CreateSubscriptionPayload.php +++ b/src/Http/Payload/CreateSubscriptionPayload.php @@ -58,7 +58,7 @@ public function __construct( $this->profileId = $profileId; } - public function data(): array + public function toArray(): array { return [ 'amount' => $this->amount, diff --git a/src/Http/Payload/DataBag.php b/src/Http/Payload/DataBag.php index 33826102..b883020d 100644 --- a/src/Http/Payload/DataBag.php +++ b/src/Http/Payload/DataBag.php @@ -3,16 +3,10 @@ namespace Mollie\Api\Http\Payload; use Mollie\Api\Contracts\Arrayable; -use Mollie\Api\Contracts\DataProvider; use Mollie\Api\Contracts\DataResolver; use Mollie\Api\Traits\ResolvesValues; -abstract class DataBag implements Arrayable, DataProvider, DataResolver +abstract class DataBag implements Arrayable, DataResolver { use ResolvesValues; - - public function toArray(): array - { - return $this->resolve(); - } } diff --git a/src/Http/Payload/DataCollection.php b/src/Http/Payload/DataCollection.php index 186bb6e1..bb3378d2 100644 --- a/src/Http/Payload/DataCollection.php +++ b/src/Http/Payload/DataCollection.php @@ -3,14 +3,13 @@ namespace Mollie\Api\Http\Payload; use Mollie\Api\Contracts\Arrayable; -use Mollie\Api\Contracts\DataProvider; use Mollie\Api\Contracts\DataResolver; use Mollie\Api\Traits\ResolvesValues; /** * @template T of \Mollie\Api\Contracts\DataResolver */ -class DataCollection implements Arrayable, DataProvider, DataResolver +class DataCollection implements Arrayable, DataResolver { use ResolvesValues; @@ -33,10 +32,6 @@ public static function wrap(object $subject): self return $subject; } - if ($subject instanceof DataProvider) { - return new static($subject->data()); - } - if ($subject instanceof Arrayable) { return new static($subject->toArray()); } @@ -44,11 +39,6 @@ public static function wrap(object $subject): self return new static((array) $subject); } - public function data(): array - { - return $this->toArray(); - } - public function toArray(): array { return $this->items; diff --git a/src/Http/Payload/Discount.php b/src/Http/Payload/Discount.php index ed0e1797..8d34be77 100644 --- a/src/Http/Payload/Discount.php +++ b/src/Http/Payload/Discount.php @@ -2,10 +2,10 @@ namespace Mollie\Api\Http\Payload; -use Mollie\Api\Contracts\DataProvider; +use Mollie\Api\Contracts\Arrayable; use Mollie\Api\Traits\ComposableFromArray; -class Discount implements DataProvider +class Discount implements Arrayable { use ComposableFromArray; @@ -21,7 +21,7 @@ public function __construct( $this->value = $value; } - public function data() + public function toArray(): array { return [ 'type' => $this->type, diff --git a/src/Http/Payload/EmailDetails.php b/src/Http/Payload/EmailDetails.php index 6d30e6e4..2a830eeb 100644 --- a/src/Http/Payload/EmailDetails.php +++ b/src/Http/Payload/EmailDetails.php @@ -2,10 +2,10 @@ namespace Mollie\Api\Http\Payload; -use Mollie\Api\Contracts\DataProvider; +use Mollie\Api\Contracts\Arrayable; use Mollie\Api\Traits\ComposableFromArray; -class EmailDetails implements DataProvider +class EmailDetails implements Arrayable { use ComposableFromArray; @@ -21,7 +21,7 @@ public function __construct( $this->body = $body; } - public function data() + public function toArray(): array { return [ 'subject' => $this->subject, diff --git a/src/Http/Payload/InvoiceLine.php b/src/Http/Payload/InvoiceLine.php index 160c37f9..f3ad2af3 100644 --- a/src/Http/Payload/InvoiceLine.php +++ b/src/Http/Payload/InvoiceLine.php @@ -28,7 +28,7 @@ public function __construct( $this->discount = $discount; } - public function data() + public function toArray(): array { return [ 'description' => $this->description, diff --git a/src/Http/Payload/Metadata.php b/src/Http/Payload/Metadata.php index 1b8a2e12..7e5b3c90 100644 --- a/src/Http/Payload/Metadata.php +++ b/src/Http/Payload/Metadata.php @@ -2,9 +2,9 @@ namespace Mollie\Api\Http\Payload; -use Mollie\Api\Contracts\DataProvider; +use Stringable; -class Metadata implements DataProvider +class Metadata implements Stringable { public array $data; @@ -13,7 +13,7 @@ public function __construct(array $data) $this->data = $data; } - public function data(): string + public function __toString(): string { return @json_encode($this->data); } diff --git a/src/Http/Payload/Money.php b/src/Http/Payload/Money.php index 45214ba3..a72286ce 100644 --- a/src/Http/Payload/Money.php +++ b/src/Http/Payload/Money.php @@ -2,9 +2,9 @@ namespace Mollie\Api\Http\Payload; -use Mollie\Api\Contracts\DataProvider; +use Mollie\Api\Contracts\Arrayable; -class Money implements DataProvider +class Money implements Arrayable { public string $currency; @@ -18,7 +18,7 @@ public function __construct( $this->value = $value; } - public function data(): array + public function toArray(): array { return [ 'currency' => $this->currency, diff --git a/src/Http/Payload/OrderLine.php b/src/Http/Payload/OrderLine.php index 113e6cff..827ed2b4 100644 --- a/src/Http/Payload/OrderLine.php +++ b/src/Http/Payload/OrderLine.php @@ -60,7 +60,7 @@ public function __construct( $this->productUrl = $productUrl; } - public function data(): array + public function toArray(): array { return [ 'description' => $this->description, diff --git a/src/Http/Payload/Owner.php b/src/Http/Payload/Owner.php index be428771..174662ad 100644 --- a/src/Http/Payload/Owner.php +++ b/src/Http/Payload/Owner.php @@ -2,10 +2,10 @@ namespace Mollie\Api\Http\Payload; -use Mollie\Api\Contracts\DataProvider; +use Mollie\Api\Contracts\Arrayable; use Mollie\Api\Traits\ComposableFromArray; -class Owner implements DataProvider +class Owner implements Arrayable { use ComposableFromArray; @@ -29,7 +29,7 @@ public function __construct( $this->locale = $locale; } - public function data(): array + public function toArray(): array { return [ 'email' => $this->email, diff --git a/src/Http/Payload/OwnerAddress.php b/src/Http/Payload/OwnerAddress.php index f80c8027..92d5e57d 100644 --- a/src/Http/Payload/OwnerAddress.php +++ b/src/Http/Payload/OwnerAddress.php @@ -2,10 +2,10 @@ namespace Mollie\Api\Http\Payload; -use Mollie\Api\Contracts\DataProvider; +use Mollie\Api\Contracts\Arrayable; use Mollie\Api\Traits\ComposableFromArray; -class OwnerAddress implements DataProvider +class OwnerAddress implements Arrayable { use ComposableFromArray; @@ -33,7 +33,7 @@ public function __construct( $this->region = $region; } - public function data(): array + public function toArray(): array { return [ 'streetAndNumber' => $this->streetAndNumber, diff --git a/src/Http/Payload/PaymentDetails.php b/src/Http/Payload/PaymentDetails.php index c2e4fa9c..daa6b273 100644 --- a/src/Http/Payload/PaymentDetails.php +++ b/src/Http/Payload/PaymentDetails.php @@ -2,10 +2,10 @@ namespace Mollie\Api\Http\Payload; -use Mollie\Api\Contracts\DataProvider; +use Mollie\Api\Contracts\Arrayable; use Mollie\Api\Traits\ComposableFromArray; -class PaymentDetails implements DataProvider +class PaymentDetails implements Arrayable { use ComposableFromArray; @@ -21,7 +21,7 @@ public function __construct( $this->sourceDescription = $sourceDescription; } - public function data() + public function toArray(): array { return [ 'source' => $this->source, diff --git a/src/Http/Payload/PaymentRoute.php b/src/Http/Payload/PaymentRoute.php index cc9698dc..b61e5615 100644 --- a/src/Http/Payload/PaymentRoute.php +++ b/src/Http/Payload/PaymentRoute.php @@ -22,7 +22,7 @@ public function __construct( $this->delayUntil = $delayUntil; } - public function data(): array + public function toArray(): array { return [ 'amount' => $this->amount, diff --git a/src/Http/Payload/Recipient.php b/src/Http/Payload/Recipient.php index 151a9ea8..5afd881e 100644 --- a/src/Http/Payload/Recipient.php +++ b/src/Http/Payload/Recipient.php @@ -2,9 +2,9 @@ namespace Mollie\Api\Http\Payload; -use Mollie\Api\Contracts\DataProvider; +use Mollie\Api\Contracts\Arrayable; -class Recipient implements DataProvider +class Recipient implements Arrayable { public string $type; @@ -74,7 +74,7 @@ public function __construct( $this->locale = $locale; } - public function data() + public function toArray(): array { return [ 'type' => $this->type, diff --git a/src/Http/Payload/RecurringBillingCycle.php b/src/Http/Payload/RecurringBillingCycle.php index e468e6d5..73892d47 100644 --- a/src/Http/Payload/RecurringBillingCycle.php +++ b/src/Http/Payload/RecurringBillingCycle.php @@ -35,7 +35,7 @@ public function __construct( $this->startDate = $startDate; } - public function data(): array + public function toArray(): array { return [ 'interval' => $this->interval, diff --git a/src/Http/Payload/RefundRoute.php b/src/Http/Payload/RefundRoute.php index 240a5555..09b29054 100644 --- a/src/Http/Payload/RefundRoute.php +++ b/src/Http/Payload/RefundRoute.php @@ -16,7 +16,7 @@ public function __construct( $this->organizationId = $organizationId; } - public function data(): array + public function toArray(): array { return [ 'amount' => $this->amount, diff --git a/src/Http/Payload/RequestApplePayPaymentSessionPayload.php b/src/Http/Payload/RequestApplePayPaymentSessionPayload.php index cdd550e5..c4b1e651 100644 --- a/src/Http/Payload/RequestApplePayPaymentSessionPayload.php +++ b/src/Http/Payload/RequestApplePayPaymentSessionPayload.php @@ -20,7 +20,7 @@ public function __construct( $this->profileId = $profileId; } - public function data(): array + public function toArray(): array { return [ 'domain' => $this->domain, diff --git a/src/Http/Payload/UpdatePaymentLinkPayload.php b/src/Http/Payload/UpdatePaymentLinkPayload.php index 83444ff7..c7aa67e3 100644 --- a/src/Http/Payload/UpdatePaymentLinkPayload.php +++ b/src/Http/Payload/UpdatePaymentLinkPayload.php @@ -16,7 +16,7 @@ public function __construct( $this->archived = $archived; } - public function data(): array + public function toArray(): array { return [ 'description' => $this->description, diff --git a/src/Http/Payload/UpdatePaymentPayload.php b/src/Http/Payload/UpdatePaymentPayload.php index 1f390d3c..455d01c7 100644 --- a/src/Http/Payload/UpdatePaymentPayload.php +++ b/src/Http/Payload/UpdatePaymentPayload.php @@ -49,7 +49,7 @@ public function __construct( $this->additional = $additional; } - public function data(): array + public function toArray(): array { return array_merge([ 'description' => $this->description, diff --git a/src/Http/Payload/UpdatePaymentRoutePayload.php b/src/Http/Payload/UpdatePaymentRoutePayload.php index 490bc810..0b5354f2 100644 --- a/src/Http/Payload/UpdatePaymentRoutePayload.php +++ b/src/Http/Payload/UpdatePaymentRoutePayload.php @@ -14,7 +14,7 @@ public function __construct( $this->releaseDate = $releaseDate; } - public function data(): array + public function toArray(): array { return [ 'releaseDate' => $this->releaseDate->format('Y-m-d'), diff --git a/src/Http/Payload/UpdateProfilePayload.php b/src/Http/Payload/UpdateProfilePayload.php index ebe735c2..53167ae3 100644 --- a/src/Http/Payload/UpdateProfilePayload.php +++ b/src/Http/Payload/UpdateProfilePayload.php @@ -40,7 +40,7 @@ public function __construct( $this->mode = $mode; } - public function data(): array + public function toArray(): array { return [ 'name' => $this->name, diff --git a/src/Http/Payload/UpdateSalesInvoicePayload.php b/src/Http/Payload/UpdateSalesInvoicePayload.php index 56634fc2..0ecc1627 100644 --- a/src/Http/Payload/UpdateSalesInvoicePayload.php +++ b/src/Http/Payload/UpdateSalesInvoicePayload.php @@ -51,7 +51,7 @@ public function __construct( $this->discount = $discount; } - public function data(): array + public function toArray(): array { return [ 'status' => $this->status, diff --git a/src/Http/Payload/UpdateSubscriptionPayload.php b/src/Http/Payload/UpdateSubscriptionPayload.php index 669f6cec..d0dde998 100644 --- a/src/Http/Payload/UpdateSubscriptionPayload.php +++ b/src/Http/Payload/UpdateSubscriptionPayload.php @@ -42,7 +42,7 @@ public function __construct( $this->mandateId = $mandateId; } - public function data(): array + public function toArray(): array { return [ 'amount' => $this->amount, diff --git a/src/Http/Requests/CreateClientLinkRequest.php b/src/Http/Requests/CreateClientLinkRequest.php index c7c97c28..f6b9cf64 100644 --- a/src/Http/Requests/CreateClientLinkRequest.php +++ b/src/Http/Requests/CreateClientLinkRequest.php @@ -31,7 +31,7 @@ public function __construct(CreateClientLinkPayload $payload) protected function defaultPayload(): array { - return $this->payload->data(); + return $this->payload->toArray(); } public function resolveResourcePath(): string diff --git a/src/Traits/ResolvesValues.php b/src/Traits/ResolvesValues.php index 87ba7882..41566556 100644 --- a/src/Traits/ResolvesValues.php +++ b/src/Traits/ResolvesValues.php @@ -2,9 +2,10 @@ namespace Mollie\Api\Traits; -use Mollie\Api\Contracts\DataProvider; +use Mollie\Api\Contracts\Arrayable; use Mollie\Api\Contracts\DataResolver; use Mollie\Api\Http\Payload\DataCollection; +use Stringable; trait ResolvesValues { @@ -16,8 +17,12 @@ public function resolve(): array return $value->resolve(); } - if ($value instanceof DataProvider) { - return $value->data(); + if ($value instanceof Arrayable) { + return $value->toArray(); + } + + if ($value instanceof Stringable) { + return $value->__toString(); } return $value; diff --git a/tests/Traits/ResolvesValuesTest.php b/tests/Traits/ResolvesValuesTest.php index 752af8d7..81a90bf2 100644 --- a/tests/Traits/ResolvesValuesTest.php +++ b/tests/Traits/ResolvesValuesTest.php @@ -3,7 +3,6 @@ namespace Tests\Traits; use Mollie\Api\Contracts\Arrayable; -use Mollie\Api\Contracts\DataProvider; use Mollie\Api\Contracts\DataResolver; use Mollie\Api\Traits\ResolvesValues; use Tests\TestCase; @@ -64,7 +63,7 @@ public function __construct(Baz $baz) $this->baz = $baz; } - public function data(): array + public function toArray(): array { return [ 'baz' => $this->baz, @@ -72,7 +71,7 @@ public function data(): array } } -class Baz implements DataProvider +class Baz implements Arrayable { public string $value; @@ -81,7 +80,7 @@ public function __construct(string $value) $this->value = $value; } - public function data(): array + public function toArray(): array { return [ 'value' => $this->value,