This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Cette classe contient des fonctions de vérification de format ou de type |
||
5 | * @version 1.0 |
||
6 | */ |
||
7 | class Is |
||
0 ignored issues
–
show
|
|||
8 | { |
||
9 | /** |
||
10 | * Vérifie si le paramètre est un ID correct |
||
11 | * @param mixed $valeur : La variable testée |
||
12 | * @return bool : VRAI si le paramètre est un entier positif (0 toléré) |
||
13 | */ |
||
14 | View Code Duplication | public static function id($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
15 | { |
||
16 | if (!self::chaineOuNombre($valeur)) { |
||
17 | $retour = false; |
||
18 | } else { |
||
19 | $retour = (bool)preg_match('#^[0-9]+$#', $valeur); |
||
20 | } |
||
21 | return $retour; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Vérifie si le paramètre est un entier |
||
26 | * @param mixed $valeur : La variable testée |
||
27 | * @return bool : VRAI si le paramètre est un entier |
||
28 | */ |
||
29 | View Code Duplication | public static function integer($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
30 | { |
||
31 | if (!self::chaineOuNombre($valeur)) { |
||
32 | $retour = false; |
||
33 | } else { |
||
34 | $retour = (bool)preg_match('#^-?[0-9]+$#', $valeur); |
||
35 | } |
||
36 | return $retour; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Vérifie si la valeur décimale du paramètre est égale à un demi de un |
||
41 | * @param mixed $valeur : La variable testée |
||
42 | * @return bool : VRAI si la valeur décimale du paramètre est égale à un demi de un |
||
43 | */ |
||
44 | public static function half($valeur) |
||
45 | { |
||
46 | return (bool)(self::chaineOuNombre($valeur) && abs($valeur - floor($valeur) - 0.5) < 0.0001); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Vérifie si le paramètre est un décimal |
||
51 | * @param mixed $valeur : La variable testée |
||
52 | * @return bool : VRAI si le paramètre est un décimal (virgule ou point acceptés) |
||
53 | */ |
||
54 | View Code Duplication | public static function decimal($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
55 | { |
||
56 | if (!self::chaineOuNombre($valeur)) { |
||
57 | $retour = false; |
||
58 | } else { |
||
59 | $retour = (bool)preg_match('#^-?(?:[0-9]+[\.,]?[0-9]*|[0-9]*[\.,]?[0-9]+)$#', $valeur); |
||
60 | } |
||
61 | return $retour; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Cette fonction teste si le paramètre est true ou false |
||
66 | * @param mixed $valeur : La variable testée |
||
67 | * @return bool : VRAI si le paramètre est un booléen |
||
68 | */ |
||
69 | public static function booleen($valeur) |
||
70 | { |
||
71 | $retour = false; |
||
72 | if ($valeur === true || $valeur === false) { |
||
73 | $retour = true; |
||
74 | } |
||
75 | return $retour; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Cette fonction teste si le paramètre un nombre pair |
||
80 | * @param mixed $valeur : La variable testée |
||
81 | * @return bool : VRAI si le paramètre est un nombre et qu'il est pair |
||
82 | */ |
||
83 | public static function pair($valeur) |
||
84 | { |
||
85 | $retour = false; |
||
86 | if (self::integer($valeur) && !($valeur % 2)) { |
||
87 | $retour = true; |
||
88 | } |
||
89 | return $retour; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Cette fonction teste le type du paramètre |
||
94 | * @param mixed $valeur : La variable testée |
||
95 | * @return bool : VRAI si le paramètre n'est pas un tableau, un booléen ou un objet |
||
96 | */ |
||
97 | public static function chaineOuNombre($valeur) |
||
98 | { |
||
99 | return !(is_object($valeur) || is_array($valeur) || self::booleen($valeur)); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Teste si le paramètre passé est alphanumérique |
||
104 | * @param string $valeur : La valeur doit être comprise entre "0" et "9", "A" et "z", "a" et "z" ou être "_" |
||
105 | * @return : VRAI si la valeur passée en paramètre est alphanumérique |
||
0 ignored issues
–
show
The doc-type
: could not be parsed: Unknown type name ":" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
106 | */ |
||
107 | View Code Duplication | public static function alphaNumerique($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
108 | { |
||
109 | if (!self::chaineOuNombre($valeur)) { |
||
110 | $retour = false; |
||
111 | } else { |
||
112 | $retour = (bool)preg_match('#^\w*$#', $valeur); |
||
113 | } |
||
114 | return $retour; |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * Fonction vérifiant le numéro de téléphone passé en paramètre |
||
119 | * @param mixed $valeur : La variable testée |
||
120 | * @return bool |
||
121 | * VRAI si la chaine passée en paramètre est un numéro de téléphone |
||
122 | * valide faisant de 10 à 20 caractères, |
||
123 | * espaces, "+" et "." tolérés |
||
124 | */ |
||
125 | View Code Duplication | public static function telephone($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
126 | { |
||
127 | if (!self::chaineOuNombre($valeur)) { |
||
128 | $retour = false; |
||
129 | } else { |
||
130 | $retour = (bool)preg_match('#^(\+){0,1}(\d|\s|\(|\)|\.){10,20}$#i', $valeur); |
||
131 | } |
||
132 | return $retour; |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * Fonction vérifiant le numéro de téléphone portable |
||
137 | * @param mixed $valeur : La variable testée |
||
138 | * @return bool |
||
139 | * VRAI si le paramètre est une chaine numérique de 10 caractères commençant par 06 ou 07, |
||
140 | * pas de séparateur toléré |
||
141 | */ |
||
142 | View Code Duplication | public static function telephonePortable($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
143 | { |
||
144 | if (!self::chaineOuNombre($valeur)) { |
||
145 | $retour = false; |
||
146 | } else { |
||
147 | $retour = (bool)preg_match('#^0(6|7)(\d){8}$#i', $valeur); |
||
148 | } |
||
149 | return $retour; |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * Fonction déterminant si une valeur est un numéro de compte général |
||
154 | * @param mixed $valeur : La variable testée |
||
155 | * @return bool : VRAI si le paramètre est une chaine numérique de 14 caractères maximum |
||
156 | */ |
||
157 | View Code Duplication | public static function compteGeneral($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
158 | { |
||
159 | if (!self::chaineOuNombre($valeur)) { |
||
160 | $retour = false; |
||
161 | } else { |
||
162 | $retour = (bool)preg_match('#^[0-9]{1,14}$#', $valeur); |
||
163 | } |
||
164 | return $retour; |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Fonction déterminant si une valeur est un numéro de compte tiers |
||
169 | * @param mixed $valeur : La variable testée |
||
170 | * @return bool : VRAI si le paramètre est une chaine alphanumérique de 17 caractères maximum |
||
171 | */ |
||
172 | View Code Duplication | public static function compteTiers($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
173 | { |
||
174 | if (!self::chaineOuNombre($valeur)) { |
||
175 | $retour = false; |
||
176 | } else { |
||
177 | $retour = (bool)preg_match('#^\w{1,17}$#', $valeur); |
||
178 | } |
||
179 | return $retour; |
||
180 | } |
||
181 | |||
182 | /** |
||
183 | * Valide que la date donnée au format français (SANS heure) existe bien |
||
184 | * @param mixed $valeur : La variable testée |
||
185 | * @return bool |
||
186 | * VRAI si la valeur passée en paramètre une date au format JJ/MM/AAAA ou JJ/MM/AA |
||
187 | * avec comme séparateur / ou . ou - |
||
188 | */ |
||
189 | View Code Duplication | public static function date($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
190 | { |
||
191 | if (is_string($valeur)) { |
||
192 | $resultat = preg_split('|[/.-]|', $valeur); |
||
193 | if (count($resultat) == 3) { |
||
194 | list($jour, $mois, $annee) = $resultat; |
||
195 | if (Is::integer($jour) && Is::integer($mois) && Is::integer($annee)) { |
||
196 | if (strlen($annee) == 2) { |
||
197 | $annee = '20' . $annee; |
||
198 | } |
||
199 | return ($annee < 1000 || $annee > 9999) ? false : checkDate($mois, $jour, $annee); |
||
200 | } |
||
201 | } |
||
202 | } |
||
203 | return false; |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * Valide que la date donnée au format français (SANS heure) existe bien |
||
208 | * @param mixed $valeur : La variable testée |
||
209 | * @return bool : VRAI si la valeur passée en paramètre une date au format JJMMAAAA ou JJMMAA, sans séparateur |
||
210 | */ |
||
211 | public static function dateWithoutSeparator($valeur) |
||
212 | { |
||
213 | if (is_string($valeur)) { |
||
214 | if (strlen($valeur) == 8) { |
||
215 | $jour = substr($valeur, -8, 2); |
||
216 | $mois = substr($valeur, -6, 2); |
||
217 | $annee = substr($valeur, -4); |
||
218 | } elseif (strlen($valeur) == 6) { |
||
219 | $jour = substr($valeur, -6, 2); |
||
220 | $mois = substr($valeur, -4, 2); |
||
221 | $annee = substr($valeur, -2); |
||
222 | } else { |
||
223 | return false; |
||
224 | } |
||
225 | if (Is::integer($jour) && Is::integer($mois) && Is::integer($annee)) { |
||
226 | if (strlen($annee) == 2) { |
||
227 | $annee = '20' . $annee; |
||
228 | } |
||
229 | if ($annee < 1000) { |
||
230 | return false; |
||
231 | } |
||
232 | if ($annee > 9999) { |
||
233 | return false; |
||
234 | } |
||
235 | return checkDate($mois, $jour, $annee); |
||
236 | } |
||
237 | } |
||
238 | return false; |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * Valide que la date donnée au format américain (SANS heure) existe bien |
||
243 | * @param mixed $valeur : La variable testée |
||
244 | * @return bool |
||
245 | * VRAI si la valeur passée en paramètre une date zu format AAAA-MM-JJ ou AA-MM-JJ |
||
246 | * avec comme séparateur / ou . ou - |
||
247 | */ |
||
248 | View Code Duplication | public static function dateUk($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
249 | { |
||
250 | if (is_string($valeur)) { |
||
251 | $resultat = preg_split('|[/.-]|', $valeur); |
||
252 | if (count($resultat) == 3) { |
||
253 | list($annee, $mois, $jour) = $resultat; |
||
254 | if (Is::integer($jour) && Is::integer($mois) && Is::integer($annee)) { |
||
255 | if (strlen($annee) == 2) { |
||
256 | $annee = '20' . $annee; |
||
257 | } |
||
258 | return ($annee < 1000 || $annee > 9999) ? false : checkDate($mois, $jour, $annee); |
||
259 | } |
||
260 | } |
||
261 | } |
||
262 | return false; |
||
263 | } |
||
264 | |||
265 | /** |
||
266 | * Valide que la date donnée au format français (avec ou sans heure) existe bien |
||
267 | * @param mixed $valeur : La variable testée |
||
268 | * @return bool |
||
269 | * VRAI si la valeur passée en paramètre une date au format JJ/MM/AAAA ou JJ/MM/AA |
||
270 | * avec comme séparateur / ou . ou - |
||
271 | */ |
||
272 | View Code Duplication | public static function dateTime($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
273 | { |
||
274 | $retour = false; |
||
275 | if (is_string($valeur)) { |
||
276 | $resultat = preg_split('|\ |', $valeur); |
||
277 | $retour = self::date($resultat[0]); |
||
278 | // Cas date + heure |
||
279 | if (count($resultat) == 2) { |
||
280 | $retour = $retour && self::heure($resultat[1]); |
||
281 | } |
||
282 | } |
||
283 | return $retour; |
||
284 | } |
||
285 | |||
286 | /** |
||
287 | * Valide que la date donnée au format américain (avec ou sans heure) existe bien |
||
288 | * @param mixed $valeur : La variable testée |
||
289 | * @return bool |
||
290 | * VRAI si la valeur passée en paramètre une date au format AAAA-MM-JJ ou AA-MM-JJ |
||
291 | * avec comme séparateur / ou . ou - |
||
292 | */ |
||
293 | View Code Duplication | public static function dateTimeUk($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
294 | { |
||
295 | if ($valeur instanceof \DateTime) { |
||
296 | return true; |
||
297 | } |
||
298 | $retour = false; |
||
299 | if (is_string($valeur)) { |
||
300 | $resultat = preg_split('|\ |', $valeur); |
||
301 | $retour = self::dateUk($resultat[0]); |
||
302 | // Cas date + heure |
||
303 | if (count($resultat) == 2) { |
||
304 | $retour = $retour && self::heure($resultat[1]); |
||
305 | } |
||
306 | } |
||
307 | return $retour; |
||
308 | } |
||
309 | |||
310 | /** |
||
311 | * Teste si la chaine passée en paramètre est une adresse email valide |
||
312 | * @param mixed $valeur : La variable testée |
||
313 | * @return bool : VRAI si la valeur passée en paramètre est une adresse email valide |
||
314 | */ |
||
315 | public static function courriel($valeur) |
||
316 | { |
||
317 | if (!self::chaineOuNombre($valeur)) { |
||
318 | $retour = false; |
||
319 | } else { |
||
320 | $retour = (bool)preg_match('#^[a-z0-9]+[-\w\?\.\+]*@[-\w]+(?:\.[-\w]+)*\.[a-z]{2,5}$#i', $valeur); |
||
321 | if ($retour && (bool)preg_match('#\.\.#', $valeur)) { |
||
322 | $retour = false; |
||
323 | } |
||
324 | } |
||
325 | return $retour; |
||
326 | } |
||
327 | |||
328 | /** |
||
329 | * Teste si la chaine passée en paramètre est une heure valide |
||
330 | * @param mixed $valeur : La variable testée |
||
331 | * @return bool |
||
332 | * VRAI si la valeur passée en paramètre est une heure valide |
||
333 | * sous la forme hh:mm:ss, secondes non obligatoires |
||
334 | */ |
||
335 | View Code Duplication | public static function heure($valeur) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
336 | { |
||
337 | if (!self::chaineOuNombre($valeur)) { |
||
338 | $retour = false; |
||
339 | } else { |
||
340 | $retour = (bool)preg_match('#^(([01][0-9])|(2[0-3]))(:[0-5][0-9])(:[0-5][0-9])?$#', $valeur); |
||
341 | } |
||
342 | return $retour; |
||
343 | } |
||
344 | |||
345 | /** |
||
346 | * Teste si la chaine passée en paramètre est un RIB valide |
||
347 | * @param mixed $valeur : La variable testée |
||
348 | * @return bool |
||
349 | * VRAI si la valeur passée en paramètre est un RIB valide |
||
350 | * (chaine texte de 24 caractères, espaces bien placés tolérés) |
||
351 | */ |
||
352 | public static function rib(&$valeur) |
||
353 | { |
||
354 | $regexp = '|^\s*(?P<cbanque>\d{5})\s*' . |
||
355 | '(?P<cguichet>\d{5})\s*(?P<nocompte>[a-z0-9]{11})\s*(?P<clerib>\d{2})\s*$|i'; |
||
356 | if (!self::chaineOuNombre($valeur) || |
||
357 | !preg_match($regexp, $valeur, $matches) |
||
358 | ) { |
||
359 | return false; |
||
360 | } |
||
361 | extract($matches); |
||
362 | $valeur = $cbanque . $cguichet . $nocompte . $clerib; |
||
363 | $tabcompte = ""; |
||
364 | $len = strlen($nocompte); |
||
365 | if ($len != 11) { |
||
366 | return false; |
||
367 | } |
||
368 | for ($i = 0; $i < $len; $i++) { |
||
369 | $caractere = substr($nocompte, $i, 1); |
||
370 | if (!is_numeric($caractere)) { |
||
371 | $car = ord($caractere) - 64; |
||
372 | $nombre = ($car < 10) ? $car : (($car < 19) ? $car - 9 : $car - 17); |
||
373 | $tabcompte .= $nombre; |
||
374 | } else { |
||
375 | $tabcompte .= $caractere; |
||
376 | } |
||
377 | } |
||
378 | $int = $cbanque . $cguichet . $tabcompte . $clerib; |
||
379 | return (strlen($int) >= 21 && bcmod($int, 97) == 0); |
||
380 | } |
||
381 | } |
||
382 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.