1 | <?php |
||
19 | class Criteria implements \IteratorAggregate, \Countable |
||
20 | { |
||
21 | /** |
||
22 | * Criteria storage. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $criteria; |
||
27 | |||
28 | /** |
||
29 | * Constructor. |
||
30 | * |
||
31 | * @param array $criteria An array of criteria |
||
32 | */ |
||
33 | 90 | public function __construct(array $criteria = []) |
|
37 | |||
38 | /** |
||
39 | * Returns the criteria. |
||
40 | * |
||
41 | * @return array An array of criteria |
||
42 | */ |
||
43 | 87 | public function all() |
|
47 | |||
48 | /** |
||
49 | * Adds criteria. |
||
50 | * |
||
51 | * @param array $criteria An array of criteria |
||
52 | */ |
||
53 | public function add(array $criteria = array()) |
||
57 | |||
58 | /** |
||
59 | * Returns a parameter by name. |
||
60 | * |
||
61 | * @param string $key The key |
||
62 | * @param mixed $default The default value if the parameter key does not exist |
||
63 | * |
||
64 | * @return mixed |
||
65 | */ |
||
66 | 87 | public function get($key, $default = null) |
|
70 | |||
71 | /** |
||
72 | * Sets a parameter by name. |
||
73 | * |
||
74 | * @param string $key The key |
||
75 | * @param mixed $value The value |
||
76 | */ |
||
77 | 15 | public function set($key, $value) |
|
81 | |||
82 | /** |
||
83 | * Returns true if the parameter is defined. |
||
84 | * |
||
85 | * @param string $key The key |
||
86 | * |
||
87 | * @return bool true if the parameter exists, false otherwise |
||
88 | */ |
||
89 | 87 | public function has($key) |
|
93 | |||
94 | /** |
||
95 | * Removes a parameter. |
||
96 | * |
||
97 | * @param string $key The key |
||
98 | */ |
||
99 | 3 | public function remove($key) |
|
100 | { |
||
101 | 3 | unset($this->criteria[$key]); |
|
102 | 3 | } |
|
103 | |||
104 | /** |
||
105 | * Returns an iterator for criteria. |
||
106 | * |
||
107 | * @return \ArrayIterator An \ArrayIterator instance |
||
108 | */ |
||
109 | public function getIterator() |
||
113 | |||
114 | /** |
||
115 | * Returns the number of criteria. |
||
116 | * |
||
117 | * @return int The number of criteria |
||
118 | */ |
||
119 | public function count() |
||
123 | } |
||
124 |