Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / common / lib / Doctrine / Common / Collections / ExpressionBuilder.php
1 <?php
2 /*
3  * THIS SOFTWARE IS PROVIDED BY THE COPYvalue HOLDERS AND CONTRIBUTORS
4  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYvalue
7  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  *
15  * This software consists of voluntary contributions made by many individuals
16  * and is licensed under the MIT license. For more information, see
17  * <http://www.doctrine-project.org>.
18  */
19
20 namespace Doctrine\Common\Collections;
21
22 use Doctrine\Common\Collections\Expr\Comparison;
23 use Doctrine\Common\Collections\Expr\CompositeExpression;
24 use Doctrine\Common\Collections\Expr\Value;
25
26 /**
27  * Builder for Expressions in the {@link Selectable} interface.
28  *
29  * @author Benjamin Eberlei <kontakt@beberlei.de>
30  * @since 2.3
31  */
32 class ExpressionBuilder
33 {
34     /**
35      * @return CompositeExpression
36      */
37     public function andX($x = null)
38     {
39         return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
40     }
41
42     /**
43      * @return CompositeExpression
44      */
45     public function orX($x = null)
46     {
47         return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args());
48     }
49
50     /**
51      * @param string $field
52      * @param mixed $value
53      *
54      * @return Comparison
55      */
56     public function eq($field, $value)
57     {
58         return new Comparison($field, Comparison::EQ, new Value($value));
59     }
60
61     /**
62      * @param string $field
63      * @param mixed $value
64      *
65      * @return Comparison
66      */
67     public function gt($field, $value)
68     {
69         return new Comparison($field, Comparison::GT, new Value($value));
70     }
71
72     /**
73      * @param string $field
74      * @param mixed $value
75      *
76      * @return Comparison
77      */
78     public function lt($field, $value)
79     {
80         return new Comparison($field, Comparison::LT, new Value($value));
81     }
82
83     /**
84      * @param string $field
85      * @param mixed $value
86      *
87      * @return Comparison
88      */
89     public function gte($field, $value)
90     {
91         return new Comparison($field, Comparison::GTE, new Value($value));
92     }
93
94     /**
95      * @param string $field
96      * @param mixed $value
97      *
98      * @return Comparison
99      */
100     public function lte($field, $value)
101     {
102         return new Comparison($field, Comparison::LTE, new Value($value));
103     }
104
105     /**
106      * @param string $field
107      * @param mixed $value
108      *
109      * @return Comparison
110      */
111     public function neq($field, $value)
112     {
113         return new Comparison($field, Comparison::NEQ, new Value($value));
114     }
115
116     /**
117      * @param string $field
118      * @param mixed $value
119      *
120      * @return Comparison
121      */
122     public function isNull($field)
123     {
124         return new Comparison($field, Comparison::IS, new Value(null));
125     }
126
127     /**
128      * @param string $field
129      * @param mixed $value
130      *
131      * @return Comparison
132      */
133     public function in($field, array $values)
134     {
135         return new Comparison($field, Comparison::IN, new Value($values));
136     }
137
138     /**
139      * @param string $field
140      * @param mixed $value
141      *
142      * @return Comparison
143      */
144     public function notIn($field, array $values)
145     {
146         return new Comparison($field, Comparison::NIN, new Value($values));
147     }
148 }
149