Skip to content

Commit 33a7d9c

Browse files
committed
map drop keys to snake case in toArray
1 parent ed804d1 commit 33a7d9c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Drop.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public function toArray(): array
2626
$result = [];
2727

2828
foreach ($this->getMetadata()->properties as $property) {
29-
$result[$property] = $this->{$property};
29+
$result[Str::snake($property)] = $this->{$property};
3030
}
3131

3232
foreach ($this->getMetadata()->dynamicProperties as $property) {
33-
$result[$property] = $this->{$property};
33+
$result[Str::snake($property)] = $this->{$property};
3434
}
3535

3636
foreach ($this->getMetadata()->invokableMethods as $method) {
37-
$result[$method] = $this->{$method};
37+
$result[Str::snake($method)] = $this->{$method};
3838
}
3939

4040
return $result;

tests/Integration/DropTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@
114114
$drop = new ProductDrop;
115115
$drop->setContext($context);
116116
expect($drop->toArray())
117-
->toHaveKeys(['productName', 'text', 'catchAll', 'context'])
118-
->productName->toBe('Product')
117+
->toHaveKeys(['product_name', 'text', 'catch_all', 'context'])
118+
->product_name->toBe('Product')
119119
->text->toBeInstanceOf(\Keepsuit\Liquid\Tests\Stubs\TextDrop::class)
120-
->catchAll->toBeInstanceOf(\Keepsuit\Liquid\Tests\Stubs\CatchAllDrop::class)
120+
->catch_all->toBeInstanceOf(\Keepsuit\Liquid\Tests\Stubs\CatchAllDrop::class)
121121
->context->toBe($context);
122122
});
123123

0 commit comments

Comments
 (0)