vendor/symfony/uid/UuidV4.php line 19

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Uid;
  11. /**
  12.  * A v4 UUID contains a 122-bit random number.
  13.  *
  14.  * @author GrĂ©goire Pineau <lyrixx@lyrixx.info>
  15.  */
  16. class UuidV4 extends Uuid
  17. {
  18.     protected const TYPE 4;
  19.     public function __construct(string $uuid null)
  20.     {
  21.         if (null === $uuid) {
  22.             $uuid random_bytes(16);
  23.             $uuid[6] = $uuid[6] & "\x0F" "\x40";
  24.             $uuid[8] = $uuid[8] & "\x3F" "\x80";
  25.             $uuid bin2hex($uuid);
  26.             $this->uid substr($uuid08).'-'.substr($uuid84).'-'.substr($uuid124).'-'.substr($uuid164).'-'.substr($uuid2012);
  27.         } else {
  28.             parent::__construct($uuid);
  29.         }
  30.     }
  31. }