Skip to content
Merged
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
32 changes: 10 additions & 22 deletions src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}

/**
Expand Down Expand Up @@ -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()));
}

/**
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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()));
}

/**
Expand Down