X-Git-Url: https://git.rapsys.eu/userbundle/blobdiff_plain/9fc280d8e9c1d65b9cddda1ce1644fc03322ffb8..ff6e3ffbf591297d4e58abe6f7c1e168fc43569d:/Utils/Slugger.php?ds=inline diff --git a/Utils/Slugger.php b/Utils/Slugger.php index 2172515..b3f18e2 100644 --- a/Utils/Slugger.php +++ b/Utils/Slugger.php @@ -23,7 +23,7 @@ class Slugger { //Retrieve secret and set offset from reduction public function __construct(ContainerInterface $container) { //Set secret - $this->secret = $container->getParameter('kernel.secret'); + $this->secret = $_SERVER['APP_SECRET'] ?? $container->getParameter('kernel.secret'); //Pseudo-random alphabet //XXX: use array flip and keys to workaround php "smart" that cast range('0', '9') as int instead of string @@ -66,7 +66,7 @@ class Slugger { } //Short the string - public function short($string) { + public function short(string $string): string { //Return string $ret = ''; @@ -83,7 +83,7 @@ class Slugger { } //Unshort the string - public function unshort($string) { + public function unshort(string $string): string { //Return string $ret = ''; @@ -98,12 +98,12 @@ class Slugger { } //Crypt and base64uri encode string - public function hash($string) { + public function hash(string $string): string { return str_replace(['+','/'], ['-','_'], base64_encode(crypt($string, $this->secret))); } //Convert string to safe slug - function slug($string) { + function slug(string $string): string { return preg_replace('/[\/_|+ -]+/', '-', strtolower(trim(preg_replace('/[^a-zA-Z0-9\/_|+ -]/', '', str_replace(['\'', '"'], ' ', iconv('UTF-8', 'ASCII//TRANSLIT', $string))), '-'))); } }