mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Regex - isValidBundleName() method - returns information if given name of bundle is valid
This commit is contained in:
@@ -37,6 +37,7 @@ class Regex
|
||||
'windowsBasedPath' => '/^[A-Z]{1}:\\\.*$/',
|
||||
'money' => '/^[-+]?\d+([\.,]{1}\d*)?$/',
|
||||
'color' => '/^[a-f0-9]{6}$/i',
|
||||
'bundleName' => '/^(([A-Z]{1}[a-z0-9]+)((?2))*)(Bundle)$/',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -723,4 +724,21 @@ class Regex
|
||||
|
||||
return strtolower($color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information if given name of bundle is valid
|
||||
*
|
||||
* @param string $bundleName Full name of bundle to verify, e.g. "MyExtraBundle"
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValidBundleName($bundleName)
|
||||
{
|
||||
if (!is_string($bundleName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pattern = self::$patterns['bundleName'];
|
||||
|
||||
return (bool)preg_match($pattern, $bundleName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user