Habari\UUID::__construct PHP Method

__construct() public method

Currently, only version 4 UUIDs are supported (Section 4.4, "Algorithms for Creating a UUID from Truly Random or Pseudo-Random Numbers").
public __construct ( integer $version = 4 )
$version integer UUID version to generate (currently, only version 4 is supported)
    public function __construct($version = 4)
    {
        $uuid = array();
        for ($i = 0; $i < 16; $i++) {
            $uuid[] = mt_rand(0, 255);
        }
        // variant (bit 6 = 1, bit 7 = 0)
        $uuid[8] = $uuid[8] & 0x3f | 0x80;
        /* // weird byte orders make my head hurt!
        		// version (bits 4-7 = 0100);
        		$uuid[7] = ( $uuid[7] & 0x0f ) | 0x40;
        		*/
        // version (bits 12-15 = 0100)
        $uuid[6] = $uuid[6] & 0xf | 0x40;
        $this->uuid = $uuid;
    }