Skip to content

Commit c1b1628

Browse files
Improving readability (#56847)
1 parent fca7209 commit c1b1628

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,13 @@ protected function ensureCastsAreStringValues($casts)
792792
foreach ($casts as $attribute => $cast) {
793793
$casts[$attribute] = match (true) {
794794
is_object($cast) => value(function () use ($cast, $attribute) {
795-
return $cast instanceof Stringable
796-
? (string) $cast
797-
: throw new InvalidArgumentException(
798-
"The cast object for the {$attribute} attribute must implement Stringable."
799-
);
795+
if ($cast instanceof Stringable) {
796+
return (string) $cast;
797+
}
798+
799+
throw new InvalidArgumentException(
800+
"The cast object for the {$attribute} attribute must implement Stringable."
801+
);
800802
}),
801803
is_array($cast) => value(function () use ($cast) {
802804
if (count($cast) === 1) {

0 commit comments

Comments
 (0)