Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
36
core/lib/Drupal/Component/Uuid/Uuid.php
Normal file
36
core/lib/Drupal/Component/Uuid/Uuid.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Component\Uuid\Uuid.
|
||||
*/
|
||||
|
||||
namespace Drupal\Component\Uuid;
|
||||
|
||||
/**
|
||||
* UUID Helper methods.
|
||||
*/
|
||||
class Uuid {
|
||||
|
||||
/**
|
||||
* The pattern used to validate a UUID string.
|
||||
*/
|
||||
const VALID_PATTERN = '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}';
|
||||
|
||||
/**
|
||||
* Checks that a string appears to be in the format of a UUID.
|
||||
*
|
||||
* Implementations should not implement validation, since UUIDs should be in
|
||||
* a consistent format across all implementations.
|
||||
*
|
||||
* @param string $uuid
|
||||
* The string to test.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the string is well formed, FALSE otherwise.
|
||||
*/
|
||||
public static function isValid($uuid) {
|
||||
return (bool) preg_match('/^' . self::VALID_PATTERN . '$/', $uuid);
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue