Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
95.45% covered (success)
95.45%
21 / 22
95.00% covered (success)
95.00%
19 / 20
CRAP
0.00% covered (danger)
0.00%
0 / 1
ExpressionBuilderAdapter
95.45% covered (success)
95.45%
21 / 22
95.00% covered (success)
95.00%
19 / 20
21
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSupportedTokenType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 parameter
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 string
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isNull
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 eq
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 neq
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 gt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 gte
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 lt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 lte
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 in
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 notIn
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 contains
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
2.15
 notContains
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 andX
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 nandX
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 orX
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 norX
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 xorX
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Symftony\Xpression\Bridge\Doctrine\Common;
6
7use Doctrine\Common\Collections\ExpressionBuilder;
8use Symftony\Xpression\Exception\Expr\UnsupportedExpressionTypeException;
9use Symftony\Xpression\Expr\ExpressionBuilderInterface;
10use Symftony\Xpression\Lexer;
11
12class ExpressionBuilderAdapter implements ExpressionBuilderInterface
13{
14    public function __construct(
15        private ExpressionBuilder $expressionBuilder
16    ) {}
17
18    public function getSupportedTokenType(): int
19    {
20        return Lexer::T_ALL - Lexer::T_NOT_AND - Lexer::T_NOT_OR - Lexer::T_XOR - Lexer::T_NOT_DOUBLE_OPEN_CURLY_BRACKET;
21    }
22
23    public function parameter(mixed $value, bool $isValue = false): mixed
24    {
25        return $value;
26    }
27
28    public function string(mixed $value): mixed
29    {
30        return $value;
31    }
32
33    public function isNull(string $field): mixed
34    {
35        return $this->expressionBuilder->isNull($field);
36    }
37
38    public function eq(string $field, mixed $value): mixed
39    {
40        return $this->expressionBuilder->eq($field, $value);
41    }
42
43    public function neq(string $field, mixed $value): mixed
44    {
45        return $this->expressionBuilder->neq($field, $value);
46    }
47
48    public function gt(string $field, mixed $value): mixed
49    {
50        return $this->expressionBuilder->gt($field, $value);
51    }
52
53    public function gte(string $field, mixed $value): mixed
54    {
55        return $this->expressionBuilder->gte($field, $value);
56    }
57
58    public function lt(string $field, mixed $value): mixed
59    {
60        return $this->expressionBuilder->lt($field, $value);
61    }
62
63    public function lte(string $field, mixed $value): mixed
64    {
65        return $this->expressionBuilder->lte($field, $value);
66    }
67
68    public function in(string $field, array $values): mixed
69    {
70        return $this->expressionBuilder->in($field, $values);
71    }
72
73    public function notIn(string $field, array $values): mixed
74    {
75        return $this->expressionBuilder->notIn($field, $values);
76    }
77
78    /**
79     * /!\ Contains operator appear only in doctrine/common v1.1 /!\.
80     */
81    public function contains(string $field, mixed $value): mixed
82    {
83        if (!method_exists($this->expressionBuilder, 'contains')) {
84            throw new UnsupportedExpressionTypeException('contains');
85        }
86
87        return $this->expressionBuilder->contains($field, $value);
88    }
89
90    public function notContains(string $field, mixed $value): mixed
91    {
92        throw new UnsupportedExpressionTypeException('notContains');
93    }
94
95    public function andX(array $expressions): mixed
96    {
97        return $this->expressionBuilder->andX(...$expressions);
98    }
99
100    public function nandX(array $expressions): mixed
101    {
102        throw new UnsupportedExpressionTypeException('nandX');
103    }
104
105    public function orX(array $expressions): mixed
106    {
107        return $this->expressionBuilder->orX(...$expressions);
108    }
109
110    public function norX(array $expressions): mixed
111    {
112        throw new UnsupportedExpressionTypeException('norX');
113    }
114
115    public function xorX(array $expressions): mixed
116    {
117        throw new UnsupportedExpressionTypeException('xorX');
118    }
119}