Loading src/Exception/FilterParameterValueIsNullException.php 0 → 100644 +15 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace IQDEV\Packages\DoctrineHttpFilter\Exception; use Exception; class FilterParameterValueIsNullException extends Exception { public function __construct(string $key) { parent::__construct('Filter parameter value of key [' . $key . '] is null.'); } } src/Filter/Where.php +6 −0 Original line number Diff line number Diff line Loading @@ -5,16 +5,22 @@ declare(strict_types=1); namespace IQDEV\Packages\DoctrineHttpFilter\Filter; use Doctrine\ORM\QueryBuilder; use IQDEV\Packages\DoctrineHttpFilter\Exception\FilterParameterValueIsNullException; use IQDEV\Packages\DoctrineHttpFilter\HttpFilter; final class Where extends HttpFilter { /** @throws FilterParameterValueIsNullException */ public function addToQuery(QueryBuilder $queryBuilder): QueryBuilder { $queryBuilder->where( $this->getColumn() . ' = :' . $this->getParameterKey(), ); if ($this->getHttpValue() === null) { throw new FilterParameterValueIsNullException($this->field); } $queryBuilder->setParameter($this->getParameterKey(), $this->getHttpValue()); return $queryBuilder; Loading src/HttpFilter.php +3 −3 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ abstract class HttpFilter public function __construct( protected string $tableAlias, protected string $filed, protected string $field, ?Request $request = null, ) { $this->request = $request ?? Request::createFromGlobals(); Loading @@ -23,7 +23,7 @@ abstract class HttpFilter protected function getColumn(): string { return $this->tableAlias . '.' . $this->filed; return $this->tableAlias . '.' . $this->field; } protected function getHttpValue(): mixed Loading @@ -37,7 +37,7 @@ abstract class HttpFilter return null; } return $filter[$this->filed] ?? null; return $filter[$this->field] ?? null; } public function getParameterKey(): string Loading Loading
src/Exception/FilterParameterValueIsNullException.php 0 → 100644 +15 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace IQDEV\Packages\DoctrineHttpFilter\Exception; use Exception; class FilterParameterValueIsNullException extends Exception { public function __construct(string $key) { parent::__construct('Filter parameter value of key [' . $key . '] is null.'); } }
src/Filter/Where.php +6 −0 Original line number Diff line number Diff line Loading @@ -5,16 +5,22 @@ declare(strict_types=1); namespace IQDEV\Packages\DoctrineHttpFilter\Filter; use Doctrine\ORM\QueryBuilder; use IQDEV\Packages\DoctrineHttpFilter\Exception\FilterParameterValueIsNullException; use IQDEV\Packages\DoctrineHttpFilter\HttpFilter; final class Where extends HttpFilter { /** @throws FilterParameterValueIsNullException */ public function addToQuery(QueryBuilder $queryBuilder): QueryBuilder { $queryBuilder->where( $this->getColumn() . ' = :' . $this->getParameterKey(), ); if ($this->getHttpValue() === null) { throw new FilterParameterValueIsNullException($this->field); } $queryBuilder->setParameter($this->getParameterKey(), $this->getHttpValue()); return $queryBuilder; Loading
src/HttpFilter.php +3 −3 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ abstract class HttpFilter public function __construct( protected string $tableAlias, protected string $filed, protected string $field, ?Request $request = null, ) { $this->request = $request ?? Request::createFromGlobals(); Loading @@ -23,7 +23,7 @@ abstract class HttpFilter protected function getColumn(): string { return $this->tableAlias . '.' . $this->filed; return $this->tableAlias . '.' . $this->field; } protected function getHttpValue(): mixed Loading @@ -37,7 +37,7 @@ abstract class HttpFilter return null; } return $filter[$this->filed] ?? null; return $filter[$this->field] ?? null; } public function getParameterKey(): string Loading