Skip to content

Commit 27e7b9f

Browse files
committed
filter array in toDotTranslations
1 parent cd40e84 commit 27e7b9f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Collections/JsonTranslations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function sortNatural(): static
2121

2222
public function toDotTranslations(): Collection
2323
{
24-
return $this->toBase();
24+
return $this->toBase()->filter()->filter(fn ($value) => $value !== [] && $value !== null);
2525
}
2626

2727
public function toTranslationsKeys(): Collection

src/Collections/PhpTranslations.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ protected function recursiveSortNatural(array $items): array
6767

6868
public function toDotTranslations(): Collection
6969
{
70-
return $this->dot()->toBase();
70+
/**
71+
* Filtering the array prevent incoherent values such as such as 'key' => []
72+
*/
73+
return $this->dot()->toBase()->filter(fn ($value) => $value !== [] && $value !== null);
7174
}
7275

7376
public function toTranslationsKeys(): Collection

0 commit comments

Comments
 (0)