Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
zakariaarrid committed Oct 25, 2024
1 parent 9e4a277 commit d398e68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
27 changes: 13 additions & 14 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1776,16 +1776,16 @@ protected function addDateBasedWhere($type, $column, $operator, $value, $boolean
/**
* Add a whenWhere to the query.
*
* @param mixed $condition
* @param string $column
* @param string|null $operator
* @param mixed|null $value
* @param string $boolean
* @param mixed $condition
* @param string $column
* @param string|null $operator
* @param mixed|null $value
* @param string $boolean
* @return $this
*/
public function whenWhere($condition, string $column, $operator = null, $value = null, string $boolean = 'and')
*/
public function whenWhere($condition, $column, $operator = null, $value = null, string $boolean = 'and')
{
if(!$condition) {
if (! $condition) {
return $this;
}

Expand All @@ -1795,14 +1795,13 @@ public function whenWhere($condition, string $column, $operator = null, $value =
/**
* Add a or whenWhere to the query.
*
* @param mixed $condition
* @param string $column
* @param string|null $operator
* @param mixed|null $value
* @param string
* @param mixed $condition
* @param string $column
* @param string|null $operator
* @param mixed|null $value
* @return $this
*/
public function orWhenWhere($condition, string $column, $operator = null, $value = null)
public function orWhenWhere($condition, $column, $operator = null, $value = null)
{
return $this->whenWhere($condition, $column, $operator, $value, 'or');
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/Database/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,13 @@ public function testChunkMap()

public function testWhenWhere()
{
$this->assertSame(1, DB::table('posts')->whenWhere(true,'id', 1)->count());
$this->assertSame(2, DB::table('posts')->whenWhere(false,'id', 1)->count());
$this->assertSame(1, DB::table('posts')->whenWhere(true, 'id', 1)->count());
$this->assertSame(2, DB::table('posts')->whenWhere(false, 'id', 1)->count());
}
public function testOrWhenWhere()
{
$this->assertSame(1, DB::table('posts')->whenWhere(true,'id', 1)->count());
$this->assertSame(2, DB::table('posts')->whenWhere(false,'id', 1)->count());
$this->assertSame(1, DB::table('posts')->whenWhere(true, 'id', 1)->count());
$this->assertSame(2, DB::table('posts')->whenWhere(false, 'id', 1)->count());
}
public function testPluck()
{
Expand Down

0 comments on commit d398e68

Please sign in to comment.