Mercurial > hg > cmmr2012-drupal-site
comparison core/lib/Drupal/Component/Uuid/Uuid.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Component\Uuid; | |
4 | |
5 /** | |
6 * UUID Helper methods. | |
7 */ | |
8 class Uuid { | |
9 | |
10 /** | |
11 * The pattern used to validate a UUID string. | |
12 */ | |
13 const VALID_PATTERN = '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}'; | |
14 | |
15 /** | |
16 * Checks whether a string appears to be in the format of a UUID. | |
17 * | |
18 * Implementations should not implement validation, since UUIDs should be in | |
19 * a consistent format across all implementations. | |
20 * | |
21 * @param string $uuid | |
22 * The string to test. | |
23 * | |
24 * @return bool | |
25 * TRUE if the string is well formed, FALSE otherwise. | |
26 */ | |
27 public static function isValid($uuid) { | |
28 return (bool) preg_match('/^' . self::VALID_PATTERN . '$/', $uuid); | |
29 } | |
30 | |
31 } |