Skip to content

Commit c958008

Browse files
authored
refactor (#57552)
1 parent f97d17b commit c958008

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -961,15 +961,12 @@ public function toArray()
961961
public function jsonSerialize(): array
962962
{
963963
return array_map(function ($value) {
964-
if ($value instanceof JsonSerializable) {
965-
return $value->jsonSerialize();
966-
} elseif ($value instanceof Jsonable) {
967-
return json_decode($value->toJson(), true);
968-
} elseif ($value instanceof Arrayable) {
969-
return $value->toArray();
970-
}
971-
972-
return $value;
964+
return match (true) {
965+
$value instanceof JsonSerializable => $value->jsonSerialize(),
966+
$value instanceof Jsonable => json_decode($value->toJson(), true),
967+
$value instanceof Arrayable => $value->toArray(),
968+
default => $value,
969+
};
973970
}, $this->all());
974971
}
975972

0 commit comments

Comments
 (0)