mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Regex - isBinaryValue() method - returns information if given value is a binary value
This commit is contained in:
@@ -39,6 +39,7 @@ class Regex
|
||||
'money' => '/^[-+]?\d+([\.,]{1}\d*)?$/',
|
||||
'color' => '/^[a-f0-9]{6}$/i',
|
||||
'bundleName' => '/^(([A-Z]{1}[a-z0-9]+)((?2))*)(Bundle)$/',
|
||||
'binaryValue' => '/[^\x20-\x7E\t\r\n]/',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -796,4 +797,21 @@ class Regex
|
||||
|
||||
return (bool)preg_match_all($pattern, $htmlAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information if given value is a binary value
|
||||
*
|
||||
* @param string $value Value to verify
|
||||
* @return bool
|
||||
*/
|
||||
public static function isBinaryValue($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pattern = self::$patterns['binaryValue'];
|
||||
|
||||
return (bool)preg_match($pattern, $value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user