Esempio n. 1
0
File: Uuid.php Progetto: averor/cqrs
 /**
  * Uuid constructor
  * @param string|null $uuid
  */
 public function __construct($uuid = null)
 {
     if ($uuid instanceof Uuid) {
         $uuid = $uuid->toString();
     } elseif (null === $uuid) {
         $uuid = UuidV4::generate();
     } elseif (!UuidV4::validate($uuid)) {
         throw new \InvalidArgumentException('Invalid UUID string given');
     }
     $this->uuid = $uuid;
 }
Esempio n. 2
0
 /**
  * @param  string|null $uuid
  * @throws InvalidArgumentException
  */
 public function __construct($uuid = null)
 {
     if (null === $uuid) {
         $uuid = Uuid::generate();
     } else {
         if (!Uuid::validate($uuid)) {
             throw new InvalidArgumentException('Given string is not valid v4 UUID');
         }
     }
     $this->uuid = (string) $uuid;
 }