@@ -20,7 +20,7 @@ |
||
20 | 20 | { |
21 | 21 | protected static function boolSnowflake() |
22 | 22 | { |
23 | - static::saving(function ($model) { |
|
23 | + static::saving(function($model) { |
|
24 | 24 | if (is_null($model->getKey())) { |
25 | 25 | $model->setIncrementing(false); |
26 | 26 | $keyName = $model->getKeyName(); |
@@ -24,7 +24,7 @@ |
||
24 | 24 | $this->mergeConfigFrom( |
25 | 25 | dirname(__DIR__) . '/../config/snowflake.php', 'snowflake' |
26 | 26 | ); |
27 | - $this->app->singleton('snowflake', function ($app) { |
|
27 | + $this->app->singleton('snowflake', function($app) { |
|
28 | 28 | return new Snowflake($app->config['snowflake']); |
29 | 29 | }); |
30 | 30 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function next(): string |
203 | 203 | { |
204 | - $id = Cache::lock($this->getCacheKey('lock'))->get(function () { |
|
204 | + $id = Cache::lock($this->getCacheKey('lock'))->get(function() { |
|
205 | 205 | $timestamp = $this->timeGen(); |
206 | 206 | |
207 | 207 | // 如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常 |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | 'worker_id' => 0, |
255 | 255 | 'data_center_id' => 0, |
256 | 256 | 'timestamp' => 0 |
257 | - ])->map(function ($value, $key) use ($len, $snowflakeId) { |
|
257 | + ])->map(function($value, $key) use ($len, $snowflakeId) { |
|
258 | 258 | $shift = $this->getData(Str::camel($key) . 'Shift', 0); |
259 | 259 | if ($len < $shift) { |
260 | 260 | throw new InvalidArgumentException(sprintf('\'%s\' is not valid snowflake id.', strval('0b' . $snowflakeId))); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | private function getLastTimestamp(): ?Carbon |
288 | 288 | { |
289 | - return Cache::rememberForever($this->getCacheKey('last timestamp'), function () { |
|
289 | + return Cache::rememberForever($this->getCacheKey('last timestamp'), function() { |
|
290 | 290 | return null; |
291 | 291 | }); |
292 | 292 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | private function getSequence(Carbon $tts): int |
306 | 306 | { |
307 | 307 | $key = $this->getCacheKey([$tts->timestamp, $tts->millisecond]); |
308 | - $sequence = Cache::remember($key, 1, function () { |
|
308 | + $sequence = Cache::remember($key, 1, function() { |
|
309 | 309 | return -1; |
310 | 310 | }); |
311 | 311 | $sequence = ($sequence + 1) & $this->sequenceMask; |