Skip to content

Commit

Permalink
Remove unnecessary nesting in Macroable trait (#14222)
Browse files Browse the repository at this point in the history
  • Loading branch information
dansoppelsa authored and taylorotwell committed Jul 5, 2016
1 parent c68cee9 commit 3b21dc6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/Illuminate/Support/Traits/Macroable.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public static function hasMacro($name)
*/
public static function __callStatic($method, $parameters)
{
if (static::hasMacro($method)) {
if (static::$macros[$method] instanceof Closure) {
return call_user_func_array(Closure::bind(static::$macros[$method], null, static::class), $parameters);
} else {
return call_user_func_array(static::$macros[$method], $parameters);
}
if (! static::hasMacro($method)) {
throw new BadMethodCallException("Method {$method} does not exist.");
}

throw new BadMethodCallException("Method {$method} does not exist.");
if (static::$macros[$method] instanceof Closure) {
return call_user_func_array(Closure::bind(static::$macros[$method], null, static::class), $parameters);
}

return call_user_func_array(static::$macros[$method], $parameters);
}

/**
Expand All @@ -70,14 +70,14 @@ public static function __callStatic($method, $parameters)
*/
public function __call($method, $parameters)
{
if (static::hasMacro($method)) {
if (static::$macros[$method] instanceof Closure) {
return call_user_func_array(static::$macros[$method]->bindTo($this, static::class), $parameters);
} else {
return call_user_func_array(static::$macros[$method], $parameters);
}
if (! static::hasMacro($method)) {
throw new BadMethodCallException("Method {$method} does not exist.");
}

if (static::$macros[$method] instanceof Closure) {
return call_user_func_array(static::$macros[$method]->bindTo($this, static::class), $parameters);
}

throw new BadMethodCallException("Method {$method} does not exist.");
return call_user_func_array(static::$macros[$method], $parameters);
}
}

0 comments on commit 3b21dc6

Please sign in to comment.