id ?: 0) : 0; self::$instance = new SnowflakeGenerator( $nodeId, $workerId, array_merge([ 'node_id_bits' => 3, 'worker_id_bits' => 7, 'sequence_bits' => 12, ], config('core.uuid.snowflake', [])) ); } return self::$instance; } /** * 静态代理调用:将所有静态方法调用转发到真正的 Snowflake 实例上 * * @param string $method 方法名,比如 "generate" * @param array $args 参数列表 * * @return mixed * @throws \core\exception\handler\AdminException */ public static function __callStatic(string $method, array $args) { $instance = self::instance(); if (!method_exists($instance, $method)) { throw new AdminException(sprintf( 'Call to undefined method %s::%s()', static::class, $method )); } return $instance->{$method}(...$args); } }