1: <?php
2: namespace NGS\Patterns;
3:
4: use \NGS\Converter\PrimitiveConverter;
5:
6: abstract class Search
7: {
8: protected $limit;
9: protected $offset;
10: protected $order = array();
11:
12: public abstract function search();
13:
14: public function limit($limit) { return $this->take($limit); }
15: public function take($limit)
16: {
17: $this->limit = PrimitiveConverter::toInteger($limit);
18: return $this;
19: }
20:
21: public function offset($offset) { return $this->skip($offset); }
22: public function skip($offset)
23: {
24: $this->offset = PrimitiveConverter::toInteger($offset);
25: return $this;
26: }
27:
28: public function asc($property) { return $this->ascending($property); }
29: public function ascending($property)
30: {
31: $this->order[PrimitiveConverter::toString($property)] = true;
32: return $this;
33: }
34:
35: public function desc($property) { return $this->descending($property); }
36: public function descending($property)
37: {
38: $this->order[PrimitiveConverter::toString($property)] = false;
39: return $this;
40: }
41: }
42: