bandwidthThrottle\tokenBucket\util\DoublePacker::unpack PHP Метод

unpack() публичный статический Метод

Unpacks a 64 bit double from an 8 byte string.
public static unpack ( string $string ) : double
$string string packed 8 byte string representation.
Результат double unpacked 64 bit double
    public static function unpack($string)
    {
        if (strlen($string) !== 8) {
            throw new StorageException("The string is not 64 bit long.");
        }
        $unpack = unpack("d", $string);
        if (!is_array($unpack) || !array_key_exists(1, $unpack)) {
            throw new StorageException("Could not unpack string.");
        }
        return $unpack[1];
    }

Usage Example

 /**
  * @SuppressWarnings(PHPMD)
  */
 public function getMicrotime()
 {
     if (fseek($this->fileHandle, 0) !== 0) {
         throw new StorageException("Could not move to beginning of the file.");
     }
     $data = fread($this->fileHandle, 8);
     if ($data === false) {
         throw new StorageException("Could not read from storage.");
     }
     return DoublePacker::unpack($data);
 }
All Usage Examples Of bandwidthThrottle\tokenBucket\util\DoublePacker::unpack
DoublePacker