Попытка реализовать отдельный компонент для oAuth авторизации в свой же API. Не тестировал, не проверял работу, просто пушнул, чтобы потом продолжить в дргуом месте.

This commit is contained in:
ErickSkrauch
2016-08-04 01:07:21 +03:00
parent 71d9511d8e
commit 26b37c2f6b
13 changed files with 241 additions and 8 deletions

View File

@@ -3,7 +3,7 @@ namespace common\helpers;
class StringHelper {
public static function getEmailMask($email) {
public static function getEmailMask(string $email) : string {
$username = explode('@', $email)[0];
$usernameLength = mb_strlen($username);
$maskChars = '**';
@@ -21,4 +21,16 @@ class StringHelper {
return $mask . mb_substr($email, $usernameLength);
}
/**
* Проверяет на то, что переданная строка является валидным UUID
* Regex найдено на просторах интернета: http://stackoverflow.com/a/6223221
*
* @param string $uuid
* @return bool
*/
public static function isUuid(string $uuid) : bool {
$re = '/[a-f0-9]{8}\-[a-f0-9]{4}\-4[a-f0-9]{3}\-(8|9|a|b)[a-f0-9]{3}\-[a-f0-9]{12}/';
return preg_match($re, $uuid, $matches) === 1;
}
}