Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Deprecate Stringable test and whenTest methods #46345

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Illuminate/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ public function matchAll($pattern)
*
* @param string $pattern
* @return bool
*
* @deprecated use isMatch instead
*/
public function test($pattern)
{
Expand Down Expand Up @@ -980,6 +982,19 @@ public function whenExactly($value, $callback, $default = null)
return $this->when($this->exactly($value), $callback, $default);
}

/**
* Execute the given callback if the string matches the given pattern.
*
* @param string|iterable<string> $pattern
* @param callable $callback
* @param callable|null $default
* @return static
*/
public function whenMatch($pattern, $callback, $default = null)
{
return $this->when($this->isMatch($pattern), $callback, $default);
}

/**
* Execute the given callback if the string is not an exact match with the given value.
*
Expand Down Expand Up @@ -1062,6 +1077,8 @@ public function whenStartsWith($needles, $callback, $default = null)
* @param callable $callback
* @param callable|null $default
* @return static
*
* @deprecated use whenMatch instead
*/
public function whenTest($pattern, $callback, $default = null)
{
Expand Down