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 - 2023 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 const CRITERIA_TYPE_DEFAULT = 'default';
33 const CRITERIA_TYPE_CHOICE = 'choice';
34 const CRITERIA_TYPE_EXCLUDE = 'exclude';
37 * Setter for frontend class name
39 * @param $frontendConfigEntry Configuration entry which hold the frontend class' name
42 function setFrontendConfigEntry (string $frontendConfigEntry);
45 * Getter for Frontend class name
47 * @return $frontendConfigEntry Configuration entry which hold the Frontend class' name
49 function getFrontendConfigEntry ();
52 * Checks whether given key is set
54 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
55 * @param $criteriaKey Criteria key
56 * @return $isSet Whether key is set
58 function isKeySet (string $criteriaType, string $criteriaKey);
61 * Checks whether given key is set for 'choice' type
63 * @param $criteriaKey Criteria key
64 * @return $isSet Whether key is set
66 function isChoiceKeySet (string $criteriaKey);
69 * Checks whether given key is set for 'exclude' type
71 * @param $criteriaKey Criteria key
72 * @return $isSet Whether key is set
74 function isExcludeKeySet (string $criteriaKey);
77 * Getter for criteria array
79 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
82 function getCriteriaArray (string $criteriaType = 'default');
85 * Getter for criteria array 'choice' type
89 function getCriteriaChoiceArray ();
92 * Getter for criteria array 'exclude' type
96 function getCriteriaExcludeArray ();
99 * Unsets a criteria key from all criteria types
101 * @param $criteriaKey Criteria key to unset
104 function unsetCriteria (string $criteriaKey);
107 * Add criteria, this method converts dashes to underscores because dashes
108 * are not valid for criteria keys.
110 * @param $criteriaKey Criteria key
111 * @param $criteriaValue Criteria value
112 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
115 function addCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = 'default');
118 * Sets criteria, this method converts dashes to underscores because dashes
119 * are not valid for criteria keys.
121 * @param $criteriaKey Criteria key
122 * @param $criteriaValue Criteria value
123 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
126 function setCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = 'default');
129 * Add "choice" criteria, this method converts dashes to underscores because
130 * dashes are not valid for criteria keys.
132 * @param $criteriaKey Criteria key
133 * @param $criteriaValue Criteria value
136 function addChoiceCriteria (string $criteriaKey, $criteriaValue);
139 * Add "exclude" criteria, this method converts dashes to underscores because
140 * dashes are not valid for criteria keys.
142 * @param $criteriaKey Criteria key
143 * @param $criteriaValue Criteria value
146 function addExcludeCriteria (string $criteriaKey, $criteriaValue);
149 * Add configured criteria
151 * @param $criteriaKey Criteria key
152 * @param $configEntry Configuration entry
153 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
156 function addConfiguredCriteria (string $criteriaKey, string $configEntry, string $criteriaType = 'default');
159 * Get criteria element or false if not found
161 * @param $criteriaKey The requested criteria key
162 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
163 * @return $value Whether the value of the critera or false
165 function getCriteriaElemnent (string $criteriaKey, string $criteriaType = 'default');
168 * Get criteria element or false if not found for 'choice' type
170 * @param $criteriaKey The requested criteria key
171 * @return $value Whether the value of the critera or false
173 function getCriteriaChoiceElemnent (string $criteriaKey);
176 * Get criteria element or false if not found for 'exclude' type
178 * @param $criteriaKey The requested criteria key
179 * @return $value Whether the value of the critera or false
181 function getCriteriaExcludeElemnent (string $criteriaKey);
184 * Checks whether given array entry matches
186 * @param $entryArray Array with the entries to find
187 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
188 * @return $matches Whether the entry matches or not
190 function ifEntryMatches (array $entryArray, string $criteriaType = 'default');
193 * Checks whether given array 'choice' entry matches
195 * @param $entryArray Array with the entries to find
196 * @return $matches Whether the entry matches or not
198 function ifChoiceMatches (array $entryArray);
201 * Checks whether given array 'exclude' entry matches
203 * @param $entryArray Array with the entries to find
204 * @return $matches Whether the entry matches or not
206 function ifExcludeMatches (array $entryArray);
209 * "Getter" for a cache key
211 * @param $onlyKeys Only use these keys for a cache key
212 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
213 * @return $cacheKey The key suitable for the cache system
215 function getCacheKey (array $onlyKeys = [], string $criteriaType = 'default');
218 * "Getter" for a cache key ('choice' type)
220 * @param $onlyKeys Only use these keys for a cache key
221 * @return $cacheKey The key suitable for the cache system
223 function getCacheKeyChoice (array $onlyKeys = []);
226 * "Getter" for a cache key ('exclude' type)
228 * @param $onlyKeys Only use these keys for a cache key
229 * @return $cacheKey The key suitable for the cache system
231 function getCacheKeyExclude (array $onlyKeys = []);
234 * Count 'choice' criteria, e.g. useful to find out if a database query
235 * has no limitation (search criteria).
237 * @return $count Count of all criteria entries
239 function countChoice ();
242 * Count 'exclude' criteria, e.g. useful to find out if a database query
243 * has no limitation (search criteria).
245 * @return $count Count of all criteria entries
247 function countExclude ();