Skip to content

[12.x] Refactor duplicated logic in ReplacesAttributes#56792

Merged
taylorotwell merged 1 commit into
laravel:12.xfrom
AhmedAlaa4611:refactor-ReplacesAttributes-4
Aug 27, 2025
Merged

[12.x] Refactor duplicated logic in ReplacesAttributes#56792
taylorotwell merged 1 commit into
laravel:12.xfrom
AhmedAlaa4611:refactor-ReplacesAttributes-4

Conversation

@AhmedAlaa4611

Copy link
Copy Markdown
Contributor

Continuation of: #56789 and #56790


Description

This PR refactors several validation message replacer methods that shared the same logic:

  • replaceIn()
  • replaceInArrayKeys()
  • replaceRequiredArrayKeys()
  • replaceEndsWith()
  • replaceDoesntEndWith()
  • replaceStartsWith()
  • replaceDoesntStartWith()
  • replaceDoesntContain()

Instead of duplicating the same code, these methods now delegate to the existing replaceIn() implementation.

This follows the same approach already used in replaceNotIn(), where the logic is centralized in one method and other similar methods simply call it.

protected function replaceNotIn($message, $attribute, $rule, $parameters)
{
return $this->replaceIn($message, $attribute, $rule, $parameters);
}

This change reduces code duplication and makes the code easier to maintain.

@taylorotwell taylorotwell merged commit 997e0c7 into laravel:12.x Aug 27, 2025
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants