generated from yiisoft/package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4db023
commit 86bae77
Showing
53 changed files
with
1,855 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Data\Db\Filter; | ||
|
||
use Yiisoft\Data\Reader\Filter\All as FilterAll; | ||
|
||
final class All extends GroupFilter | ||
{ | ||
public static function getOperator(): string | ||
{ | ||
return FilterAll::getOperator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Data\Db\Filter; | ||
|
||
use Yiisoft\Data\Reader\Filter\Any as FilterAny; | ||
|
||
final class Any extends GroupFilter | ||
{ | ||
public static function getOperator(): string | ||
{ | ||
return FilterAny::getOperator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Data\Db\Filter; | ||
|
||
use Yiisoft\Data\Reader\Filter\Between as BetweenFilter; | ||
use Yiisoft\Db\Expression\ExpressionInterface; | ||
|
||
final class Between implements QueryFilterInterface | ||
{ | ||
use ParamsTrait; | ||
|
||
public function __construct( | ||
private readonly string|ExpressionInterface $column, | ||
private readonly mixed $min, | ||
private readonly mixed $max, | ||
array $params = [] | ||
) { | ||
$this->params = $params; | ||
} | ||
|
||
public static function getOperator(): string | ||
{ | ||
return BetweenFilter::getOperator(); | ||
} | ||
|
||
private static function isEmpty(mixed $value): bool | ||
{ | ||
return $value === null || $value === ''; | ||
} | ||
|
||
public function toCriteriaArray(): array | ||
{ | ||
$isMinEmpty = self::isEmpty($this->min); | ||
$isMaxEmpty = self::isEmpty($this->max); | ||
|
||
if (!$isMinEmpty && !$isMaxEmpty) { | ||
return [ | ||
self::getOperator(), | ||
$this->column, | ||
$this->min, | ||
$this->max, | ||
]; | ||
} | ||
|
||
if (!$isMinEmpty) { | ||
return (new GreaterThanOrEqual($this->column, $this->min))->toCriteriaArray(); | ||
} | ||
|
||
if (!$isMaxEmpty) { | ||
return (new LessThanOrEqual($this->column, $this->max))->toCriteriaArray(); | ||
} | ||
|
||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Data\Db\Filter; | ||
|
||
use Yiisoft\Db\Expression\ExpressionInterface; | ||
|
||
abstract class CompareFilter implements QueryFilterInterface | ||
{ | ||
use ParamsTrait; | ||
|
||
protected bool $ignoreNull = false; | ||
|
||
/** | ||
* @param ExpressionInterface|string $column | ||
* @param mixed $value | ||
* @param array $params | ||
*/ | ||
public function __construct( | ||
protected readonly string|ExpressionInterface $column, | ||
protected mixed $value, | ||
array $params = [] | ||
) { | ||
$this->params = $params; | ||
} | ||
|
||
public function withIgnoreNull(bool $ignoreNull = true): static | ||
{ | ||
if ($this->ignoreNull === $ignoreNull) { | ||
return $this; | ||
} | ||
|
||
$new = clone $this; | ||
$new->ignoreNull = $ignoreNull; | ||
|
||
return $new; | ||
} | ||
|
||
public function toCriteriaArray(): array | ||
{ | ||
if ($this->value === null) { | ||
return $this->ignoreNull ? [] : (new EqualsNull($this->column))->toCriteriaArray(); | ||
} | ||
|
||
return [static::getOperator(), $this->column , $this->value]; | ||
} | ||
} |
Oops, something went wrong.