Gistrec

FIX PMMP UUID

Feb 12th, 2017
294
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1.     public static function fromBinary($uuid, $version = null){
  2.         if (strlen($uuid) < 16) $uuid = $uuid.implode("", array_fill(0, 16 - strlen($uuid), 0));
  3.         elseif (strlen($uuid) > 16) $uuid = substr($uuid, 0, 16);
  4.         if(strlen($uuid) !== 16){
  5.             var_dump($uuid, strlen($uuid));
  6.             throw new \InvalidArgumentException("Must have exactly 16 bytes");
  7.         }
  8.         return new UUID(Binary::readInt(substr($uuid, 0, 4)), Binary::readInt(substr($uuid, 4, 4)), Binary::readInt(substr($uuid, 8, 4)), Binary::readInt(substr($uuid, 12, 4)), $version);
  9.     }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment