AbstractQueryBuilderAdapter::getOperator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace Mgid\Component\Pagination\Adapter\Doctrine\ODM;
4
5
use Mgid\Component\Pagination\Contract\FilterableInterface;
6
use Mgid\Component\Pagination\Adapter\QueryBuilderAdapterInterface;
7
8
abstract class AbstractQueryBuilderAdapter implements QueryBuilderAdapterInterface
9
{
10
    private const OPERATORS = [
11
        FilterableInterface::EQUAL => '$eq',
12
        FilterableInterface::NOT_EQUAL => '$ne',
13
        FilterableInterface::IN => '$in',
14
        FilterableInterface::NOT_IN => '$nin',
15
        FilterableInterface::LESS_THEN => '$lt',
16
        FilterableInterface::LESS_THEN_OR_EQUAL => '$lte',
17
        FilterableInterface::GREATER_THEN => '$gt',
18
        FilterableInterface::GREATER_THEN_OR_EQUAL => '$gte',
19
        FilterableInterface::LIKE => '$regex',
20
    ];
21
22
    /**
23
     * @param string $alias
24
     *
25
     * @return string
26
     */
27
    protected function getOperator(string $alias): string
28
    {
29
        return self::OPERATORS[$alias];
30
    }
31
}
32