]> git.mxchange.org Git - core.git/blob - framework/main/interfaces/criteria/class_Criteria.php
0ff16acb4947eb43348377c789293525e4b5c36b
[core.git] / framework / main / interfaces / criteria / class_Criteria.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Criteria;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
7
8 /**
9  * An interface for criterias
10  *
11  * @author              Roland Haeder <webmaster@shipsimu.org>
12  * @version             0.0.0
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
16  *
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.
21  *
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.
26  *
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/>.
29  */
30 interface Criteria extends FrameworkInterface {
31         // Criteria types
32         const CRITERIA_TYPE_DEFAULT  = 'default';
33         const CRITERIA_TYPE_CHOICE   = 'choice';
34         const CRITERIA_TYPE_EXCLUDE  = 'exclude';
35
36         /**
37          * Setter for frontend class name
38          *
39          * @param       $frontendConfigEntry    Configuration entry which hold the frontend class' name
40          * @return      void
41          */
42         function setFrontendConfigEntry (string $frontendConfigEntry);
43
44         /**
45          * Getter for Frontend class name
46          *
47          * @return      $frontendConfigEntry    Configuration entry which hold the Frontend class' name
48          */
49         function getFrontendConfigEntry ();
50
51         /**
52          * Checks whether given key is set
53          *
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
57          */
58         function isKeySet (string $criteriaType, string $criteriaKey);
59
60         /**
61          * Checks whether given key is set for 'choice' type
62          *
63          * @param       $criteriaKey    Criteria key
64          * @return      $isSet                  Whether key is set
65          */
66         function isChoiceKeySet (string $criteriaKey);
67
68         /**
69          * Checks whether given key is set for 'exclude' type
70          *
71          * @param       $criteriaKey    Criteria key
72          * @return      $isSet                  Whether key is set
73          */
74         function isExcludeKeySet (string $criteriaKey);
75
76         /**
77          * Getter for criteria array
78          *
79          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
80          * @return      $criteria
81          */
82         function getCriteriaArray (string $criteriaType = 'default');
83
84         /**
85          * Getter for criteria array 'choice' type
86          *
87          * @return      $criteria
88          */
89         function getCriteriaChoiceArray ();
90
91         /**
92          * Getter for criteria array 'exclude' type
93          *
94          * @return      $criteria
95          */
96         function getCriteriaExcludeArray ();
97
98         /**
99          * Unsets a criteria key from all criteria types
100          *
101          * @param       $criteriaKey    Criteria key to unset
102          * @return      void
103          */
104         function unsetCriteria (string $criteriaKey);
105
106         /**
107          * Add criteria, this method converts dashes to underscores because dashes
108          * are not valid for criteria keys.
109          *
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'
113          * @return      void
114          */
115         function addCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = 'default');
116
117         /**
118          * Sets criteria, this method converts dashes to underscores because dashes
119          * are not valid for criteria keys.
120          *
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'
124          * @return      void
125          */
126         function setCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = 'default');
127
128         /**
129          * Add "choice" criteria, this method converts dashes to underscores because
130          * dashes are not valid for criteria keys.
131          *
132          * @param       $criteriaKey    Criteria key
133          * @param       $criteriaValue  Criteria value
134          * @return      void
135          */
136         function addChoiceCriteria (string $criteriaKey, $criteriaValue);
137
138         /**
139          * Add "exclude" criteria, this method converts dashes to underscores because
140          * dashes are not valid for criteria keys.
141          *
142          * @param       $criteriaKey    Criteria key
143          * @param       $criteriaValue  Criteria value
144          * @return      void
145          */
146         function addExcludeCriteria (string $criteriaKey, $criteriaValue);
147
148         /**
149          * Add configured criteria
150          *
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'
154          * @return      void
155          */
156         function addConfiguredCriteria (string $criteriaKey, string $configEntry, string $criteriaType = 'default');
157
158         /**
159          * Get criteria element or false if not found
160          *
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
164          */
165         function getCriteriaElemnent (string $criteriaKey, string $criteriaType = 'default');
166
167         /**
168          * Get criteria element or false if not found for 'choice' type
169          *
170          * @param       $criteriaKey    The requested criteria key
171          * @return      $value                  Whether the value of the critera or false
172          */
173         function getCriteriaChoiceElemnent (string $criteriaKey);
174
175         /**
176          * Get criteria element or false if not found for 'exclude' type
177          *
178          * @param       $criteriaKey    The requested criteria key
179          * @return      $value                  Whether the value of the critera or false
180          */
181         function getCriteriaExcludeElemnent (string $criteriaKey);
182
183         /**
184          * Checks whether given array entry matches
185          *
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
189          */
190         function ifEntryMatches (array $entryArray, string $criteriaType = 'default');
191
192         /**
193          * Checks whether given array 'choice' entry matches
194          *
195          * @param       $entryArray             Array with the entries to find
196          * @return      $matches                Whether the entry matches or not
197          */
198         function ifChoiceMatches (array $entryArray);
199
200         /**
201          * Checks whether given array 'exclude' entry matches
202          *
203          * @param       $entryArray             Array with the entries to find
204          * @return      $matches                Whether the entry matches or not
205          */
206         function ifExcludeMatches (array $entryArray);
207
208         /**
209          * "Getter" for a cache key
210          *
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
214          */
215         function getCacheKey (array $onlyKeys = [], string $criteriaType = 'default');
216
217         /**
218          * "Getter" for a cache key ('choice' type)
219          *
220          * @param       $onlyKeys       Only use these keys for a cache key
221          * @return      $cacheKey       The key suitable for the cache system
222          */
223         function getCacheKeyChoice (array $onlyKeys = []);
224
225         /**
226          * "Getter" for a cache key ('exclude' type)
227          *
228          * @param       $onlyKeys       Only use these keys for a cache key
229          * @return      $cacheKey       The key suitable for the cache system
230          */
231         function getCacheKeyExclude (array $onlyKeys = []);
232
233         /**
234          * Count 'choice' criteria, e.g. useful to find out if a database query
235          * has no limitation (search criteria).
236          *
237          * @return      $count  Count of all criteria entries
238          */
239         function countChoice ();
240
241         /**
242          * Count 'exclude' criteria, e.g. useful to find out if a database query
243          * has no limitation (search criteria).
244          *
245          * @return      $count  Count of all criteria entries
246          */
247         function countExclude ();
248
249 }