for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nayjest\Querying\Handler;
use Nayjest\Querying\Operation\FilterOperation;
trait DatabaseFilterHandlerTrait
{
abstract protected function getOperation();
protected function getOperatorAndValue()
/** @var FilterOperation $operation */
$operation = $this->getOperation();
$operator = $operation->getOperator();
$value = $operation->getValue();
switch ($operator) {
case FilterOperation::OPERATOR_STR_STARTS_WITH:
$operator = FilterOperation::OPERATOR_LIKE;
$value .= '%';
break;
case FilterOperation::OPERATOR_STR_ENDS_WITH:
$value = '%' . $value;
case FilterOperation::OPERATOR_STR_CONTAINS:
$value = '%' . $value . '%';
}
return [$operator, $value];