2025-10-13 11:41:45 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace OCP\Snowflake;
|
|
|
|
|
|
|
|
|
|
use OCP\AppFramework\Attribute\Consumable;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Nextcloud Snowflake ID decoder
|
|
|
|
|
*
|
2025-12-18 14:25:59 -05:00
|
|
|
* @see \OCP\Snowflake\ISnowflakeGenerator for format
|
2025-10-13 11:41:45 -04:00
|
|
|
* @since 33.0.0
|
|
|
|
|
*/
|
|
|
|
|
#[Consumable(since: '33.0.0')]
|
2025-12-18 14:25:59 -05:00
|
|
|
interface ISnowflakeDecoder {
|
2025-10-13 11:41:45 -04:00
|
|
|
/**
|
|
|
|
|
* Decode information contained into Snowflake ID
|
|
|
|
|
*
|
|
|
|
|
* It includes:
|
|
|
|
|
* - server ID: identify server on which ID was generated
|
|
|
|
|
* - sequence ID: sequence number (number of snowflakes generated in the same second)
|
|
|
|
|
* - createdAt: timestamp at which ID was generated
|
|
|
|
|
* - isCli: if ID was generated using CLI or not
|
|
|
|
|
*
|
2025-12-18 14:25:59 -05:00
|
|
|
* @return Snowflake
|
2025-10-13 11:41:45 -04:00
|
|
|
* @since 33.0
|
|
|
|
|
*/
|
2025-12-18 14:25:59 -05:00
|
|
|
public function decode(string $snowflakeId): Snowflake;
|
2025-10-13 11:41:45 -04:00
|
|
|
}
|