<?php

namespace Dipper\Foundation\Snowflake;

use Illuminate\Support\ServiceProvider;

class SnowflakeServiceProvider extends ServiceProvider
{
    /**
     * 显示是否延迟提供程序的加载.
     *
     * @var bool
     */
    protected $defer = true;

    /**
     * 注册一个服务提供者
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton(IdWorker::class, function ($app) {
            $macheineId = config('dipper.snowflake.macheine_id');
            $sequence = config('dipper.snowflake.sequence');
            return new IdWorker($macheineId, $sequence);
        });
    }

    /**
     * 获取提供者提供的服务
     *
     * @return array
     */
    public function provides()
    {
        return [IdWorker::class];
    }
}
