diff options
author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/collections/src/ExpressionBuilder.php | |
parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/collections/src/ExpressionBuilder.php')
-rw-r--r-- | vendor/doctrine/collections/src/ExpressionBuilder.php | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/vendor/doctrine/collections/src/ExpressionBuilder.php b/vendor/doctrine/collections/src/ExpressionBuilder.php new file mode 100644 index 0000000..fc25e3a --- /dev/null +++ b/vendor/doctrine/collections/src/ExpressionBuilder.php | |||
@@ -0,0 +1,123 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\Common\Collections; | ||
6 | |||
7 | use Doctrine\Common\Collections\Expr\Comparison; | ||
8 | use Doctrine\Common\Collections\Expr\CompositeExpression; | ||
9 | use Doctrine\Common\Collections\Expr\Expression; | ||
10 | use Doctrine\Common\Collections\Expr\Value; | ||
11 | |||
12 | /** | ||
13 | * Builder for Expressions in the {@link Selectable} interface. | ||
14 | * | ||
15 | * Important Notice for interoperable code: You have to use scalar | ||
16 | * values only for comparisons, otherwise the behavior of the comparison | ||
17 | * may be different between implementations (Array vs ORM vs ODM). | ||
18 | */ | ||
19 | class ExpressionBuilder | ||
20 | { | ||
21 | /** @return CompositeExpression */ | ||
22 | public function andX(Expression ...$expressions) | ||
23 | { | ||
24 | return new CompositeExpression(CompositeExpression::TYPE_AND, $expressions); | ||
25 | } | ||
26 | |||
27 | /** @return CompositeExpression */ | ||
28 | public function orX(Expression ...$expressions) | ||
29 | { | ||
30 | return new CompositeExpression(CompositeExpression::TYPE_OR, $expressions); | ||
31 | } | ||
32 | |||
33 | public function not(Expression $expression): CompositeExpression | ||
34 | { | ||
35 | return new CompositeExpression(CompositeExpression::TYPE_NOT, [$expression]); | ||
36 | } | ||
37 | |||
38 | /** @return Comparison */ | ||
39 | public function eq(string $field, mixed $value) | ||
40 | { | ||
41 | return new Comparison($field, Comparison::EQ, new Value($value)); | ||
42 | } | ||
43 | |||
44 | /** @return Comparison */ | ||
45 | public function gt(string $field, mixed $value) | ||
46 | { | ||
47 | return new Comparison($field, Comparison::GT, new Value($value)); | ||
48 | } | ||
49 | |||
50 | /** @return Comparison */ | ||
51 | public function lt(string $field, mixed $value) | ||
52 | { | ||
53 | return new Comparison($field, Comparison::LT, new Value($value)); | ||
54 | } | ||
55 | |||
56 | /** @return Comparison */ | ||
57 | public function gte(string $field, mixed $value) | ||
58 | { | ||
59 | return new Comparison($field, Comparison::GTE, new Value($value)); | ||
60 | } | ||
61 | |||
62 | /** @return Comparison */ | ||
63 | public function lte(string $field, mixed $value) | ||
64 | { | ||
65 | return new Comparison($field, Comparison::LTE, new Value($value)); | ||
66 | } | ||
67 | |||
68 | /** @return Comparison */ | ||
69 | public function neq(string $field, mixed $value) | ||
70 | { | ||
71 | return new Comparison($field, Comparison::NEQ, new Value($value)); | ||
72 | } | ||
73 | |||
74 | /** @return Comparison */ | ||
75 | public function isNull(string $field) | ||
76 | { | ||
77 | return new Comparison($field, Comparison::EQ, new Value(null)); | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * @param mixed[] $values | ||
82 | * | ||
83 | * @return Comparison | ||
84 | */ | ||
85 | public function in(string $field, array $values) | ||
86 | { | ||
87 | return new Comparison($field, Comparison::IN, new Value($values)); | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * @param mixed[] $values | ||
92 | * | ||
93 | * @return Comparison | ||
94 | */ | ||
95 | public function notIn(string $field, array $values) | ||
96 | { | ||
97 | return new Comparison($field, Comparison::NIN, new Value($values)); | ||
98 | } | ||
99 | |||
100 | /** @return Comparison */ | ||
101 | public function contains(string $field, mixed $value) | ||
102 | { | ||
103 | return new Comparison($field, Comparison::CONTAINS, new Value($value)); | ||
104 | } | ||
105 | |||
106 | /** @return Comparison */ | ||
107 | public function memberOf(string $field, mixed $value) | ||
108 | { | ||
109 | return new Comparison($field, Comparison::MEMBER_OF, new Value($value)); | ||
110 | } | ||
111 | |||
112 | /** @return Comparison */ | ||
113 | public function startsWith(string $field, mixed $value) | ||
114 | { | ||
115 | return new Comparison($field, Comparison::STARTS_WITH, new Value($value)); | ||
116 | } | ||
117 | |||
118 | /** @return Comparison */ | ||
119 | public function endsWith(string $field, mixed $value) | ||
120 | { | ||
121 | return new Comparison($field, Comparison::ENDS_WITH, new Value($value)); | ||
122 | } | ||
123 | } | ||