\Less_SourceMap_Base64VLQ

Encode / Decode Base64 VLQ.

Summary

Methods
Properties
Constants
__construct()
toVLQSigned()
fromVLQSigned()
encode()
decode()
zeroFill()
base64Encode()
base64Decode()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$shift
$mask
$continuationBit
$charToIntMap
$intToCharMap
N/A

Properties

$shift

$shift : integer

Shift

Type

integer

$mask

$mask : integer

Mask

Type

integer

$continuationBit

$continuationBit : integer

Continuation bit

Type

integer

$charToIntMap

$charToIntMap : array

Char to integer map

Type

array

$intToCharMap

$intToCharMap : array

Integer to char map

Type

array

Methods

__construct()

__construct() 

Constructor

toVLQSigned()

toVLQSigned(string  $aValue) 

Convert from a two-complement value to a value where the sign bit is is placed in the least significant bit. For example, as decimals: 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) We generate the value for 32 bit machines, hence -2147483648 becomes 1, not 4294967297, even on a 64 bit machine.

Parameters

string $aValue

fromVLQSigned()

fromVLQSigned(integer  $aValue) 

Convert to a two-complement value from a value where the sign bit is is placed in the least significant bit. For example, as decimals: 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 We assume that the value was generated with a 32 bit machine in mind.

Hence 1 becomes -2147483648 even on a 64 bit machine.

Parameters

integer $aValue

encode()

encode(string  $aValue) : string

Return the base 64 VLQ encoded value.

Parameters

string $aValue

The value to encode

Returns

string —

The encoded value

decode()

decode(string  $encoded) : integer

Return the value decoded from base 64 VLQ.

Parameters

string $encoded

The encoded value to decode

Returns

integer —

The decoded value

zeroFill()

zeroFill(integer  $a, integer  $b) : integer

Right shift with zero fill.

Parameters

integer $a

number to shift

integer $b

number of bits to shift

Returns

integer

base64Encode()

base64Encode(integer  $number) : string

Encode single 6-bit digit as base64.

Parameters

integer $number

Throws

\Exception

If the number is invalid

Returns

string

base64Decode()

base64Decode(string  $char) : \number

Decode single 6-bit digit from base64

Parameters

string $char

Throws

\Exception

If the number is invalid

Returns

\number