Skip to content

Commit

Permalink
use variadic
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 24, 2017
1 parent 02abb3a commit bfc5321
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/Illuminate/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,14 @@ public function is()
}

/**
* Determine if the route name matches a pattern.
* Determine if the route name matches a given pattern.
*
* @param dynamic $patterns
* @return bool
*/
public function routeIs()
public function routeIs(...$patterns)
{
return ($route = $this->route()) && call_user_func_array([$route, 'named'], func_get_args());
return $this->route() && $this->route()->named(...$patterns);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/Illuminate/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,17 +622,18 @@ public function name($name)
}

/**
* Determine whether the route's name matches a pattern.
* Determine whether the route's name matches the given patterns.
*
* @param dynamic $patterns
* @return bool
*/
public function named()
public function named(...$patterns)
{
if (is_null($routeName = $this->getName())) {
return false;
}

foreach (func_get_args() as $pattern) {
foreach ($patterns as $pattern) {
if (Str::is($pattern, $routeName)) {
return true;
}
Expand Down
10 changes: 6 additions & 4 deletions src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -941,21 +941,23 @@ public function currentRouteName()
/**
* Alias for the "currentRouteNamed" method.
*
* @param dynamic $patterns
* @return bool
*/
public function is()
public function is(...$patterns)
{
return call_user_func_array([$this, 'currentRouteNamed'], func_get_args());
return $this->currentRouteNamed(...$patterns);
}

/**
* Determine if the current route matches a pattern.
*
* @param dynamic $patterns
* @return bool
*/
public function currentRouteNamed()
public function currentRouteNamed(...$patterns)
{
return ($route = $this->current()) && call_user_func_array([$route, 'named'], func_get_args());
return $this->current() && $this->current()->named(...$patterns);
}

/**
Expand Down

0 comments on commit bfc5321

Please sign in to comment.