diff --git a/src/Illuminate/Support/Collection.php b/src/Illuminate/Support/Collection.php index 6dd11b561aa5..6c9e61ef4480 100644 --- a/src/Illuminate/Support/Collection.php +++ b/src/Illuminate/Support/Collection.php @@ -226,13 +226,7 @@ public function contains($key, $operator = null, $value = null) return in_array($key, $this->items); } - if (func_num_args() == 2) { - $value = $operator; - - $operator = '='; - } - - return $this->contains($this->operatorForWhere($key, $operator, $value)); + return $this->contains($this->operatorForWhere(...func_get_args())); } /** @@ -385,13 +379,7 @@ public function every($key, $operator = null, $value = null) return true; } - if (func_num_args() == 2) { - $value = $operator; - - $operator = '='; - } - - return $this->every($this->operatorForWhere($key, $operator, $value)); + return $this->every($this->operatorForWhere(...func_get_args())); } /** @@ -481,8 +469,14 @@ public function where($key, $operator, $value = null) * @param mixed $value * @return \Closure */ - protected function operatorForWhere($key, $operator, $value) + protected function operatorForWhere($key, $operator, $value = null) { + if (func_num_args() == 2) { + $value = $operator; + + $operator = '='; + } + return function ($item) use ($key, $operator, $value) { $retrieved = data_get($item, $key); @@ -598,13 +592,7 @@ public function first(callable $callback = null, $default = null) */ public function firstWhere($key, $operator, $value = null) { - if (func_num_args() == 2) { - $value = $operator; - - $operator = '='; - } - - return $this->first($this->operatorForWhere($key, $operator, $value)); + return $this->first($this->operatorForWhere(...func_get_args())); } /**