CBOR
CBOR
class CBORConstants
int
public const int = nullint
public const int = nullProperties
data
private string $dataType: string
length
private int $lengthType: int
maxDepth
private int $maxDepthType: int
strict
private bool $strictType: bool
Methods
__construct
private __construct(string $data, int $length, int $maxDepth, bool $strict): voidParameters
| Parameter | Type | Description |
|---|---|---|
$data | string | |
$length | int | |
$maxDepth | int | |
$strict | bool |
decode
Decodes a string holding exactly one CBOR data item.
public decode(string $data, int $maxDepth = 'self::DEFAULT_MAX_DEPTH', int $maxLength = 'self::DEFAULT_MAX_LENGTH', bool $strict): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | string | the CBOR bytes |
$maxDepth | int | the deepest nesting of arrays, maps and tags allowed |
$maxLength | int | the longest input allowed, in bytes |
$strict | bool | whether to reject integers and lengths that aren't in their shortest form |
decodeItem
Decodes one CBOR data item starting at $offset, and returns it with the offset just past it.
public decodeItem(string $data, int $offset, int $maxDepth = 'self::DEFAULT_MAX_DEPTH', int $maxLength = 'self::DEFAULT_MAX_LENGTH', bool $strict): arrayReturns: array
Use this when a data item is followed by other data, such as the credential public key inside WebAuthn authenticator data, which can be followed by an extensions map.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | string | the CBOR bytes |
$offset | int | where the data item starts |
$maxDepth | int | the deepest nesting of arrays, maps and tags allowed |
$maxLength | int | the longest input allowed, in bytes |
$strict | bool | whether to reject integers and lengths that aren't in their shortest form |
encode
Encodes a value as CBOR, in CTAP2 canonical form.
public encode(mixed $value): stringReturns: string
Plain strings are encoded as text strings and must be valid UTF-8; wrap binary data in a Hazaar\Util\CBOR\ByteString. List arrays become CBOR arrays and other arrays become maps, so an empty PHP array is an empty CBOR array. Wrap an array in a Hazaar\Util\CBOR\Map to force a map.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed |
item
private item(int $offset, int $depth): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | int | |
$depth | int |
argument
Reads the argument (count, length or value) that follows an initial byte.
private argument(int $info, int $offset, int $start): intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$info | int | |
$offset | int | |
$start | int |
simple
Decodes major type 7: simple values and floats.
private simple(int $info, int $offset, int $start): bool|float|nullReturns: bool|float|null
Parameters
| Parameter | Type | Description |
|---|---|---|
$info | int | |
$offset | int | |
$start | int |
bytes
Reads $count bytes and moves past them.
private bytes(int $offset, int $count): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | int | |
$count | int |
halfFloat
Converts an IEEE 754 half-precision float (RFC 8949 Appendix D).
private halfFloat(int $half): floatReturns: float
Parameters
| Parameter | Type | Description |
|---|---|---|
$half | int |
encodeItem
private encodeItem(mixed $value, int $depth): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | |
$depth | int |
encodeText
private encodeText(string $text): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$text | string |
encodeList
private encodeList(array $value, int $depth): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | array | |
$depth | int |
encodeMap
private encodeMap(array $value, int $depth): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | array | |
$depth | int |
head
Encodes an initial byte and its argument in the shortest form.
private head(int $major, int $argument): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$major | int | |
$argument | int |
Generated by Hazaar API Doc Generator on Wed, 28 Oct 2026 08:43:32 +0000