class Snowflake (View source)

Represents a Snowflake.

Constants

EPOCH

Time since UNIX epoch to Discord epoch.

Properties

static protected $incrementIndex
static protected $incrementTime
string|int $value The snowflake value.
float $timestamp The timestamp of when this snowflake got generated. In seconds with microseconds.
int $workerID The ID of the worker which generated this snowflake.
int $processID The ID of the process which generated this snowflake.
int $increment The increment index of the snowflake.
string $binary The binary representation of this snowflake.
DateTime $date A DateTime instance of the timestamp.

Methods

__construct(string|int $snowflake)

Constructor.

mixed
__get($name)

No description

static Snowflake
deconstruct(string|int $snowflake)

Deconstruct a snowflake.

static string
generate(int $workerID = 1, int $processID = 0)

Generates a new snowflake.

int
getShardID(int $shardCount)

Compute the shard ID from the snowflake.

Details

__construct(string|int $snowflake)

Constructor.

Parameters

string|int $snowflake

Exceptions

InvalidArgumentException

mixed __get($name)

Parameters

$name

Return Value

mixed

Exceptions

Exception

static Snowflake deconstruct(string|int $snowflake)

Deconstruct a snowflake.

Parameters

string|int $snowflake

Return Value

Snowflake

static string generate(int $workerID = 1, int $processID = 0)

Generates a new snowflake.

Parameters

int $workerID Valid values are in the range of 0-31.
int $processID Valid values are in the range of 0-31.

Return Value

string

int getShardID(int $shardCount)

Compute the shard ID from the snowflake.

Parameters

int $shardCount

Return Value

int