Skip to content

Commit 78861ff

Browse files
committed
formatting
1 parent 17befe0 commit 78861ff

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Illuminate/Validation/Concerns/ReplacesAttributes.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected function replaceAcceptedIf($message, $attribute, $rule, $parameters)
2222

2323
$parameters[0] = $this->getDisplayableAttribute($parameters[0]);
2424

25-
return $this->replaceKeepCase($message, ['other' => $parameters[0], 'value' => $parameters[1]]);
25+
return $this->replaceWhileKeepingCase($message, ['other' => $parameters[0], 'value' => $parameters[1]]);
2626
}
2727

2828
/**
@@ -333,7 +333,7 @@ protected function replaceInArray($message, $attribute, $rule, $parameters)
333333
{
334334
$value = $this->getDisplayableAttribute($parameters[0]);
335335

336-
return $this->replaceKeepCase($message, ['other' => $value]);
336+
return $this->replaceWhileKeepingCase($message, ['other' => $value]);
337337
}
338338

339339
/**
@@ -621,7 +621,7 @@ protected function replaceRequiredIfAccepted($message, $attribute, $rule, $param
621621
{
622622
$value = $this->getDisplayableAttribute($parameters[0]);
623623

624-
return $this->replaceKeepCase($message, ['other' => $value]);
624+
return $this->replaceWhileKeepingCase($message, ['other' => $value]);
625625
}
626626

627627
/**
@@ -762,7 +762,7 @@ protected function replaceSame($message, $attribute, $rule, $parameters)
762762
{
763763
$value = $this->getDisplayableAttribute($parameters[0]);
764764

765-
return $this->replaceKeepCase($message, ['other' => $value]);
765+
return $this->replaceWhileKeepingCase($message, ['other' => $value]);
766766
}
767767

768768
/**
@@ -932,16 +932,20 @@ protected function replaceDoesntContain($message, $attribute, $rule, $parameters
932932
}
933933

934934
/**
935+
* Replace the given string while maintaining different casing variants.
936+
*
935937
* @param array<string, string> $mapping
936938
*/
937-
private function replaceKeepCase(string $message, array $mapping): string
939+
private function replaceWhileKeepingCase(string $message, array $mapping): string
938940
{
939941
$fn = [Str::lower(...), Str::upper(...), Str::ucfirst(...)];
942+
940943
$cases = array_reduce(
941944
array_keys($mapping),
942945
fn (array $carry, string $placeholder) => [...$carry, ...array_map(fn (callable $fn) => ':'.$fn($placeholder), $fn)],
943946
[],
944947
);
948+
945949
$replacements = array_reduce(
946950
array_values($mapping),
947951
fn (array $carry, string $parameter) => [...$carry, ...array_map(fn (callable $fn) => $fn($parameter), $fn)],

0 commit comments

Comments
 (0)