1414
1515use Webklex \IMAP \Exceptions \InvalidWhereQueryCriteriaException ;
1616use Webklex \IMAP \Exceptions \MethodNotFoundException ;
17+ use Webklex \IMAP \Exceptions \MessageSearchValidationException ;
1718
1819/**
19- * Class Query
20+ * Class WhereQuery
2021 *
2122 * @package Webklex\IMAP\Query
2223 *
4445 * @method WhereQuery body($value)
4546 * @method WhereQuery before($date)
4647 * @method WhereQuery bcc($value)
48+ *
49+ * @mixin Query
4750 */
4851class WhereQuery extends Query {
4952
@@ -92,10 +95,11 @@ protected function validate_criteria($criteria) {
9295 }
9396
9497 /**
95- * @param string|array $criteria
96- * @param mixed $value
97- *
98+ * @param mixed $criteria
99+ * @param null $value
100+ *
98101 * @return $this
102+ * @throws InvalidWhereQueryCriteriaException
99103 */
100104 public function where ($ criteria , $ value = null ) {
101105 if (is_array ($ criteria )){
@@ -146,32 +150,35 @@ public function andWhere(\Closure $closure = null) {
146150
147151 /**
148152 * @return WhereQuery
153+ * @throws InvalidWhereQueryCriteriaException
149154 */
150155 public function whereAll () {
151156 return $ this ->where ('ALL ' );
152157 }
153158
154159 /**
155160 * @return WhereQuery
161+ * @throws InvalidWhereQueryCriteriaException
156162 */
157163 public function whereAnswered () {
158164 return $ this ->where ('ANSWERED ' );
159165 }
160166
161167 /**
162168 * @param string $value
163- *
169+ *
164170 * @return WhereQuery
171+ * @throws InvalidWhereQueryCriteriaException
165172 */
166173 public function whereBcc ($ value ) {
167174 return $ this ->where ('BCC ' , $ value );
168175 }
169176
170177 /**
171178 * @param mixed $value
172- *
173179 * @return WhereQuery
174- * @throws \Webklex\IMAP\Exceptions\MessageSearchValidationException
180+ * @throws InvalidWhereQueryCriteriaException
181+ * @throws MessageSearchValidationException
175182 */
176183 public function whereBefore ($ value ) {
177184 $ date = $ this ->parse_date ($ value );
@@ -182,6 +189,7 @@ public function whereBefore($value) {
182189 * @param string $value
183190 *
184191 * @return WhereQuery
192+ * @throws InvalidWhereQueryCriteriaException
185193 */
186194 public function whereBody ($ value ) {
187195 return $ this ->where ('BODY ' , $ value );
@@ -191,13 +199,15 @@ public function whereBody($value) {
191199 * @param string $value
192200 *
193201 * @return WhereQuery
202+ * @throws InvalidWhereQueryCriteriaException
194203 */
195204 public function whereCc ($ value ) {
196205 return $ this ->where ('CC ' , $ value );
197206 }
198207
199208 /**
200209 * @return WhereQuery
210+ * @throws InvalidWhereQueryCriteriaException
201211 */
202212 public function whereDeleted () {
203213 return $ this ->where ('DELETED ' );
@@ -207,6 +217,7 @@ public function whereDeleted() {
207217 * @param string $value
208218 *
209219 * @return WhereQuery
220+ * @throws InvalidWhereQueryCriteriaException
210221 */
211222 public function whereFlagged ($ value ) {
212223 return $ this ->where ('FLAGGED ' , $ value );
@@ -216,6 +227,7 @@ public function whereFlagged($value) {
216227 * @param string $value
217228 *
218229 * @return WhereQuery
230+ * @throws InvalidWhereQueryCriteriaException
219231 */
220232 public function whereFrom ($ value ) {
221233 return $ this ->where ('FROM ' , $ value );
@@ -225,20 +237,23 @@ public function whereFrom($value) {
225237 * @param string $value
226238 *
227239 * @return WhereQuery
240+ * @throws InvalidWhereQueryCriteriaException
228241 */
229242 public function whereKeyword ($ value ) {
230243 return $ this ->where ('KEYWORD ' , $ value );
231244 }
232245
233246 /**
234247 * @return WhereQuery
248+ * @throws InvalidWhereQueryCriteriaException
235249 */
236250 public function whereNew () {
237251 return $ this ->where ('NEW ' );
238252 }
239253
240254 /**
241255 * @return WhereQuery
256+ * @throws InvalidWhereQueryCriteriaException
242257 */
243258 public function whereOld () {
244259 return $ this ->where ('OLD ' );
@@ -248,7 +263,8 @@ public function whereOld() {
248263 * @param mixed $value
249264 *
250265 * @return WhereQuery
251- * @throws \Webklex\IMAP\Exceptions\MessageSearchValidationException
266+ * @throws MessageSearchValidationException
267+ * @throws InvalidWhereQueryCriteriaException
252268 */
253269 public function whereOn ($ value ) {
254270 $ date = $ this ->parse_date ($ value );
@@ -257,13 +273,15 @@ public function whereOn($value) {
257273
258274 /**
259275 * @return WhereQuery
276+ * @throws InvalidWhereQueryCriteriaException
260277 */
261278 public function whereRecent () {
262279 return $ this ->where ('RECENT ' );
263280 }
264281
265282 /**
266283 * @return WhereQuery
284+ * @throws InvalidWhereQueryCriteriaException
267285 */
268286 public function whereSeen () {
269287 return $ this ->where ('SEEN ' );
@@ -273,7 +291,8 @@ public function whereSeen() {
273291 * @param mixed $value
274292 *
275293 * @return WhereQuery
276- * @throws \Webklex\IMAP\Exceptions\MessageSearchValidationException
294+ * @throws MessageSearchValidationException
295+ * @throws InvalidWhereQueryCriteriaException
277296 */
278297 public function whereSince ($ value ) {
279298 $ date = $ this ->parse_date ($ value );
@@ -284,6 +303,7 @@ public function whereSince($value) {
284303 * @param string $value
285304 *
286305 * @return WhereQuery
306+ * @throws InvalidWhereQueryCriteriaException
287307 */
288308 public function whereSubject ($ value ) {
289309 return $ this ->where ('SUBJECT ' , $ value );
@@ -293,6 +313,7 @@ public function whereSubject($value) {
293313 * @param string $value
294314 *
295315 * @return WhereQuery
316+ * @throws InvalidWhereQueryCriteriaException
296317 */
297318 public function whereText ($ value ) {
298319 return $ this ->where ('TEXT ' , $ value );
@@ -302,6 +323,7 @@ public function whereText($value) {
302323 * @param string $value
303324 *
304325 * @return WhereQuery
326+ * @throws InvalidWhereQueryCriteriaException
305327 */
306328 public function whereTo ($ value ) {
307329 return $ this ->where ('TO ' , $ value );
@@ -311,34 +333,39 @@ public function whereTo($value) {
311333 * @param string $value
312334 *
313335 * @return WhereQuery
336+ * @throws InvalidWhereQueryCriteriaException
314337 */
315338 public function whereUnkeyword ($ value ) {
316339 return $ this ->where ('UNKEYWORD ' , $ value );
317340 }
318341
319342 /**
320343 * @return WhereQuery
344+ * @throws InvalidWhereQueryCriteriaException
321345 */
322346 public function whereUnanswered () {
323347 return $ this ->where ('UNANSWERED ' );
324348 }
325349
326350 /**
327351 * @return WhereQuery
352+ * @throws InvalidWhereQueryCriteriaException
328353 */
329354 public function whereUndeleted () {
330355 return $ this ->where ('UNDELETED ' );
331356 }
332357
333358 /**
334359 * @return WhereQuery
360+ * @throws InvalidWhereQueryCriteriaException
335361 */
336362 public function whereUnflagged () {
337363 return $ this ->where ('UNFLAGGED ' );
338364 }
339365
340366 /**
341367 * @return WhereQuery
368+ * @throws InvalidWhereQueryCriteriaException
342369 */
343370 public function whereUnseen () {
344371 return $ this ->where ('UNSEEN ' );
0 commit comments