3 namespace Org\Mxchange\CoreFramework\Criteria;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
9 * An interface for criterias
11 * @author Roland Haeder <webmaster@shipsimu.org>
13 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
14 * @license GNU GPL 3.0 or any newer version
15 * @link http://www.shipsimu.org
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 interface Criteria extends FrameworkInterface {
32 * Setter for wrapper class name
34 * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name
37 function setWrapperConfigEntry ($wrapperConfigEntry);
40 * Getter for wrapper class name
42 * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name
44 function getWrapperConfigEntry ();
47 * Checks whether given key is set
49 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
50 * @param $criteriaKey Criteria key
51 * @return $isSet Whether key is set
53 function isKeySet ($criteriaType, $criteriaKey);
56 * Checks whether given key is set for 'choice' type
58 * @param $criteriaKey Criteria key
59 * @return $isSet Whether key is set
61 function isChoiceKeySet ($criteriaKey);
64 * Checks whether given key is set for 'exclude' type
66 * @param $criteriaKey Criteria key
67 * @return $isSet Whether key is set
69 function isExcludeKeySet ($criteriaKey);
72 * Getter for criteria array
74 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
77 function getCriteriaArray ($criteriaType = 'default');
80 * Getter for criteria array 'choice' type
84 function getCriteriaChoiceArray ();
87 * Getter for criteria array 'exclude' type
91 function getCriteriaExcludeArray ();
94 * Unsets a criteria key from all criteria types
96 * @param $criteriaKey Criteria key to unset
99 function unsetCriteria ($criteriaKey);
102 * Add criteria, this method converts dashes to underscores because dashes
103 * are not valid for criteria keys.
105 * @param $criteriaKey Criteria key
106 * @param $criteriaValue Criteria value
107 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
110 function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default');
113 * Sets criteria, this method converts dashes to underscores because dashes
114 * are not valid for criteria keys.
116 * @param $criteriaKey Criteria key
117 * @param $criteriaValue Criteria value
118 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
121 function setCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default');
124 * Add "choice" criteria, this method converts dashes to underscores because
125 * dashes are not valid for criteria keys.
127 * @param $criteriaKey Criteria key
128 * @param $criteriaValue Criteria value
131 function addChoiceCriteria ($criteriaKey, $criteriaValue);
134 * Add "exclude" criteria, this method converts dashes to underscores because
135 * dashes are not valid for criteria keys.
137 * @param $criteriaKey Criteria key
138 * @param $criteriaValue Criteria value
141 function addExcludeCriteria ($criteriaKey, $criteriaValue);
144 * Add configured criteria
146 * @param $criteriaKey Criteria key
147 * @param $configEntry Configuration entry
148 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
151 function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default');
154 * Get criteria element or false if not found
156 * @param $criteriaKey The requested criteria key
157 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
158 * @return $value Whether the value of the critera or false
160 function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default');
163 * Get criteria element or false if not found for 'choice' type
165 * @param $criteriaKey The requested criteria key
166 * @return $value Whether the value of the critera or false
168 function getCriteriaChoiceElemnent ($criteriaKey);
171 * Get criteria element or false if not found for 'exclude' type
173 * @param $criteriaKey The requested criteria key
174 * @return $value Whether the value of the critera or false
176 function getCriteriaExcludeElemnent ($criteriaKey);
179 * Checks whether given array entry matches
181 * @param $entryArray Array with the entries to find
182 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
183 * @return $matches Whether the entry matches or not
185 function ifEntryMatches (array $entryArray, $criteriaType = 'default');
188 * Checks whether given array 'choice' entry matches
190 * @param $entryArray Array with the entries to find
191 * @return $matches Whether the entry matches or not
193 function ifChoiceMatches (array $entryArray);
196 * Checks whether given array 'exclude' entry matches
198 * @param $entryArray Array with the entries to find
199 * @return $matches Whether the entry matches or not
201 function ifExcludeMatches (array $entryArray);
204 * "Getter" for a cache key
206 * @param $onlyKeys Only use these keys for a cache key
207 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
208 * @return $cacheKey The key suitable for the cache system
210 function getCacheKey ($onlyKeys = array(), $criteriaType = 'default');
213 * "Getter" for a cache key ('choice' type)
215 * @param $onlyKeys Only use these keys for a cache key
216 * @return $cacheKey The key suitable for the cache system
218 function getCacheKeyChoice ($onlyKeys = array());
221 * "Getter" for a cache key ('exclude' type)
223 * @param $onlyKeys Only use these keys for a cache key
224 * @return $cacheKey The key suitable for the cache system
226 function getCacheKeyExclude ($onlyKeys = array());
229 * Count the criteria, e.g. useful to find out if a database query has no
230 * limitation (search criteria).
232 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
233 * @return $count Count of all criteria entries
235 function count ($criteriaType = 'default');
238 * Count 'choice' criteria, e.g. useful to find out if a database query
239 * has no limitation (search criteria).
241 * @return $count Count of all criteria entries
243 function countChoice ();
246 * Count 'exclude' criteria, e.g. useful to find out if a database query
247 * has no limitation (search criteria).
249 * @return $count Count of all criteria entries
251 function countExclude ();