nextcloud/lib/public/Snowflake/Snowflake.php
Benjamin Gaussorgues 9e36754429
fix(snowflake): fix wrong documentation about serverId
Maximum value of a server ID is 511 (9 bits) and not 1023.
Also adjust SetupCheck

Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
2026-05-12 10:47:44 +02:00

83 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Snowflake;
use OCP\AppFramework\Attribute\Consumable;
/**
* Nextcloud Snowflake DTO
*
* @since 33.0.0
*/
#[Consumable(since: '33.0.0')]
final readonly class Snowflake {
/**
* @psalm-param int<0,511> $serverId
* @psalm-param int<0,4095> $sequenceId
* @psalm-param non-negative-int $seconds
* @psalm-param int<0,999> $milliseconds
* @since 33.0.0
*/
public function __construct(
private int $serverId,
private int $sequenceId,
private bool $isCli,
private int $seconds,
private int $milliseconds,
private \DateTimeImmutable $createdAt,
) {
}
/**
* @psalm-return int<0,511>
* @since 33.0.0
*/
public function getServerId(): int {
return $this->serverId;
}
/**
* @psalm-return int<0,4095>
* @since 33.0.0
*/
public function getSequenceId(): int {
return $this->sequenceId;
}
/**
* @since 33.0.0
*/
public function isCli(): bool {
return $this->isCli;
}
/**
* @psalm-return non-negative-int
* @since 33.0.0
*/
public function getSeconds(): int {
return $this->seconds;
}
/**
* @psalm-return int<0,999>
* @since 33.0.0
*/
public function getMilliseconds(): int {
return $this->milliseconds;
}
/**
* @since 33.0.0
*/
public function getCreatedAt(): \DateTimeImmutable {
return $this->createdAt;
}
}