Completed
Push — master ( 68be21...073c54 )
by Kévin
02:41
created

PommOperators::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
3
namespace RulerZ\Target\Pomm;
4
5
use RulerZ\Target\Operators;
6
7
class PommOperators
8
{
9
    /**
10
     * @return Operators\Definitions
11
     */
12
    public static function create(Operators\Definitions $customOperators)
13
    {
14
        $definitions = Operators\GenericSqlDefinitions::create($customOperators);
15
16
        $definitions->defineInlineOperator('and', function ($a, $b) {
17
            return sprintf('%s->andWhere(%s)', $a, $b);
18
        });
19
        $definitions->defineInlineOperator('or', function ($a, $b) {
20
            return sprintf('%s->orWhere(%s)', $a, $b);
21
        });
22
        $definitions->defineInlineOperator('not', function ($a) {
23
            return sprintf('(new \PommProject\Foundation\Where("NOT(".%s->getElement() .")", %s->getValues()))', $a, $a);
24
        });
25
26
        return $definitions;
27
    }
28
}
29