-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
269 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace Core; | ||
|
||
/** | ||
* Class StandardRaw | ||
* | ||
* @author Benoit Foujols | ||
*/ | ||
class StandardRaw | ||
{ | ||
/** | ||
* Normalize to Standard Raw Upper | ||
* Rules Raw -> Clean -> Upper -> Raw (Standard) | ||
* @param String $raw | ||
* @return String|null | ||
*/ | ||
public function normalizeSRString(string $raw, bool $space = false): ?string | ||
{ | ||
return ($space === true) ? strtoupper($this->clean($this->cleanBeginToEndWhiteSpace($raw))) : strtoupper($this->clean($raw)); | ||
} | ||
|
||
/** | ||
* Normalize to Standard Raw UCFirst | ||
* Rules Raw -> Clean -> UCFirst -> Raw (Standard) | ||
* @param String $raw | ||
* @return String|null | ||
*/ | ||
public function normalizeSRSUcfirst(string $raw, bool $space = false): ?string | ||
{ | ||
return ($space === true) ? ucfirst(strtolower($this->clean($this->cleanBeginToEndWhiteSpace($raw)))) : ucfirst(strtolower($this->clean($raw))); | ||
} | ||
|
||
|
||
/** | ||
* Normalize to Standard Raw UTF8 | ||
* Rules Raw -> Clean -> Raw (Standard) | ||
* @param String $raw Source à nettoyer | ||
* @param bool $space Supprimer les espaces avant et après la source | ||
* @param bool $nonbreaking Supprimer les | ||
* @return String|null | ||
*/ | ||
public function normalizeSRUtf8(string $raw, bool $space = false, bool $nonbreaking = false): ?string | ||
{ | ||
return ($space === true) ? $this->clean($this->cleanBeginToEndWhiteSpace($raw), $nonbreaking) : $this->clean($raw, $nonbreaking); | ||
} | ||
|
||
/** | ||
* Clean String UTF8 to Normal | ||
* @param String $text | ||
* @return String|null | ||
*/ | ||
private function clean(string $text, bool $nonbreaking = false): ?string | ||
{ | ||
$utf8 = array( | ||
'/[áàâãªä]/u' => 'a', | ||
'/[ÁÀÂÃÄ]/u' => 'A', | ||
'/[ÍÌÎÏ]/u' => 'I', | ||
'/[íìîï]/u' => 'i', | ||
'/[éèêë]/u' => 'e', | ||
'/[ÉÈÊË]/u' => 'E', | ||
'/[óòôõºö]/u' => 'o', | ||
'/[ÓÒÔÕÖ]/u' => 'O', | ||
'/[úùûü]/u' => 'u', | ||
'/[ÚÙÛÜ]/u' => 'U', | ||
'/ç/' => 'c', | ||
'/Ç/' => 'C', | ||
'/ñ/' => 'n', | ||
'/Ñ/' => 'N', | ||
'/–/' => '-', // UTF-8 hyphen to "normal" hyphen | ||
'/[’‘‹›‚]/u' => ' ', // Literally a single quote | ||
'/[“”«»„]/u' => ' ', // Double quote | ||
'/[.]/' => '', | ||
); | ||
$utf8['/ /'] = ($nonbreaking === true) ? ' ' : '-'; // nonbreaking space (equiv. to 0x160) | ||
$utf8['/-/'] = ($nonbreaking === true) ? ' ' : '-'; | ||
return preg_replace(array_keys($utf8), array_values($utf8), $text); | ||
} | ||
|
||
/** | ||
* Clean whitespace Begin To End | ||
* @param String $raw | ||
* @return String|null | ||
*/ | ||
private function cleanBeginToEndWhiteSpace(string $raw): ?string | ||
{ | ||
return rtrim(ltrim($raw)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"organisation" : { | ||
"v3" : { | ||
"promo" : "2023-2024", | ||
"classes" : { | ||
"107" : { | ||
"libelle" : "1 TS SIO A", | ||
"code" : "1TSSIOA", | ||
"etudiants" : { | ||
"1" : { | ||
"nom": "Boukari", | ||
"prenom": "Abdoul", | ||
"email": "[email protected]", | ||
"telPortable": "0606060606", | ||
"sexe": "M", | ||
"login": "ABOUKARI", | ||
"idLogin" : "ABOUKARI", | ||
"password": "ABOUKARI", | ||
"uid": "98432dd9-c483-3669-a31e-153fec2eac72", | ||
"tokenExpiration": "2023-10-08 10:10:03", | ||
"lastConnexion": "2023-10-08 10:10:03", | ||
"anneeScolaireCourante": "2020-2021" | ||
} | ||
} | ||
}, | ||
"120" : { | ||
"libelle" : "1 TS SIO B", | ||
"code" : "1TSSIOB" | ||
}, | ||
"134" : { | ||
"libelle" : "1 TS SIO - année alternance", | ||
"code" : "1TSSIOALT" | ||
}, | ||
"109" : { | ||
"libelle" : "2TS SIO SLAM", | ||
"code" : "2TSSIOSLAM" | ||
}, | ||
"130" : { | ||
"libelle" : "2TS SIO SISR", | ||
"code" : "2TSSIOSISR" | ||
}, | ||
"152" : { | ||
"libelle" : "2TS SIO SLAM - année alternance", | ||
"code" : "2TSSIOSLAMALT" | ||
}, | ||
"162" : { | ||
"libelle" : "2TS SIO SISR - année alternance", | ||
"code" : "2TSSIOSISRALT" | ||
}, | ||
"140" : { | ||
"libelle" : "Bachelor CSI - année alternance", | ||
"code" : "CSIALT" | ||
}, | ||
"148" : { | ||
"libelle" : "Manager Solutions Digitals et Data 1ème - année alternance", | ||
"code" : "MS2D1ALT" | ||
}, | ||
"141" : { | ||
"libelle" : "Manager Solutions Digitals et Data 2ème - année alternance", | ||
"code" : "MS2D2ALT" | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |