diff --git a/src/Drop.php b/src/Drop.php index 589fbe4..cb0c644 100644 --- a/src/Drop.php +++ b/src/Drop.php @@ -26,15 +26,15 @@ public function toArray(): array $result = []; foreach ($this->getMetadata()->properties as $property) { - $result[$property] = $this->{$property}; + $result[Str::snake($property)] = $this->{$property}; } foreach ($this->getMetadata()->dynamicProperties as $property) { - $result[$property] = $this->{$property}; + $result[Str::snake($property)] = $this->{$property}; } foreach ($this->getMetadata()->invokableMethods as $method) { - $result[$method] = $this->{$method}; + $result[Str::snake($method)] = $this->{$method}; } return $result; diff --git a/tests/Integration/DropTest.php b/tests/Integration/DropTest.php index 03c4c0e..70ea8f4 100644 --- a/tests/Integration/DropTest.php +++ b/tests/Integration/DropTest.php @@ -114,10 +114,10 @@ $drop = new ProductDrop; $drop->setContext($context); expect($drop->toArray()) - ->toHaveKeys(['productName', 'text', 'catchAll', 'context']) - ->productName->toBe('Product') + ->toHaveKeys(['product_name', 'text', 'catch_all', 'context']) + ->product_name->toBe('Product') ->text->toBeInstanceOf(\Keepsuit\Liquid\Tests\Stubs\TextDrop::class) - ->catchAll->toBeInstanceOf(\Keepsuit\Liquid\Tests\Stubs\CatchAllDrop::class) + ->catch_all->toBeInstanceOf(\Keepsuit\Liquid\Tests\Stubs\CatchAllDrop::class) ->context->toBe($context); });