Skip to content

Commit

Permalink
Remove redundant check
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Apr 27, 2021
1 parent 5b604e1 commit 86fd558
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ protected function prepareValuesAndOther($parameters)
$values = $this->convertValuesToBoolean($values);
}

if ($this->shouldConvertToNull($parameters[0]) || is_null($other)) {
if (is_null($other)) {
$values = $this->convertValuesToNull($values);
}

Expand All @@ -1534,17 +1534,6 @@ protected function shouldConvertToBoolean($parameter)
return in_array('boolean', Arr::get($this->rules, $parameter, []));
}

/**
* Check if parameter should be converted to null.
*
* @param string $parameter
* @return bool
*/
protected function shouldConvertToNull($parameter)
{
return in_array('nullable', Arr::get($this->rules, $parameter, []));
}

/**
* Convert the given values to boolean if they are string "true" / "false".
*
Expand Down Expand Up @@ -1573,11 +1562,7 @@ protected function convertValuesToBoolean($values)
protected function convertValuesToNull($values)
{
return array_map(function ($value) {
if ($value === 'null') {
return null;
}

return $value;
return Str::lower($value) === 'null' ? null : $value;
}, $values);
}

Expand Down

0 comments on commit 86fd558

Please sign in to comment.