generated from yiisoft/package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
f36ff7e
commit 8f0ed75
Showing
30 changed files
with
682 additions
and
322 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Data\Db; | ||
|
||
use InvalidArgumentException; | ||
use Yiisoft\Db\Expression\ExpressionInterface; | ||
|
||
trait ColumnFormatterTrait | ||
{ | ||
/** | ||
* @var ExpressionInterface|string | ||
*/ | ||
protected $column; | ||
|
||
/** | ||
* @param mixed $column | ||
* @param string|null $table | ||
* | ||
* @throws InvalidArgumentException | ||
*/ | ||
private function setColumn($column, ?string $table = null): void | ||
{ | ||
if (\is_string($column)) { | ||
if ($table) { | ||
$this->column = $table . '.' . $column; | ||
} else { | ||
$this->column = $column; | ||
} | ||
} elseif ($column instanceof ExpressionInterface) { | ||
$this->column = $column; | ||
} else { | ||
$type = \is_object($column) ? \get_class($column) : \gettype($column); | ||
|
||
throw new InvalidArgumentException('Column must be string or instance of "' . ExpressionInterface::class . '". "' . $type . '" given.'); | ||
} | ||
} | ||
} |
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
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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Data\Db\Filter; | ||
|
||
use Yiisoft\Data\Db\ColumnFormatterTrait; | ||
use Yiisoft\Data\Reader\Filter\FilterInterface; | ||
|
||
final class IsNull implements FilterInterface | ||
{ | ||
use ColumnFormatterTrait; | ||
|
||
/** | ||
* @param mixed $column | ||
* @param string|null $table | ||
*/ | ||
public function __construct($column, ?string $table = null) | ||
{ | ||
$this->setColumn($column, $table); | ||
} | ||
|
||
public static function getOperator(): string | ||
{ | ||
return 'is'; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [self::getOperator(), $this->column, null]; | ||
} | ||
} |
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
Oops, something went wrong.