Skip to content

Commit 3706fc0

Browse files
committed
Move to uuid from ulid
1 parent 7426222 commit 3706fc0

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/Controlled.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ protected function execute(Closure $callback): mixed
146146

147147
$trace = Monitor::trace()->pickup();
148148
$timer = new LogTimer;
149-
$blockId = Str::ulid()->toString();
149+
$blockId = Str::uuid()->toString();
150150

151151
// Check for nested Controlled blocks
152152
$contextTracker = app(ControlledContext::class);

src/Support/ControlledContext.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
final class ControlledContext
1010
{
11-
/** @var array{name: string, ulid: string}|null */
11+
/** @var array{name: string, uuid: string}|null */
1212
protected ?array $current = null;
1313

14-
public function enter(string $name, string $ulid): void
14+
public function enter(string $name, string $uuid): void
1515
{
1616
if ($this->current !== null) {
1717
throw new NestedControlledBlockException(
18-
"Nested Controlled block detected: attempted to start '{$name}' while already in '{$this->current['name']}' (ULID: {$this->current['ulid']})."
18+
"Nested Controlled block detected: attempted to start '{$name}' while already in '{$this->current['name']}' (uuid: {$this->current['uuid']})."
1919
);
2020
}
2121

22-
$this->current = compact('name', 'ulid');
22+
$this->current = compact('name', 'uuid');
2323
}
2424

2525
public function exit(): void
@@ -32,7 +32,7 @@ public function isInside(): bool
3232
return $this->current !== null;
3333
}
3434

35-
/** @return array{name: string, ulid: string}|null */
35+
/** @return array{name: string, uuid: string}|null */
3636
public function current(): ?array
3737
{
3838
return $this->current;

tests/Unit/ControlledContextTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,48 @@
1818
});
1919

2020
it('tracks entering a controlled block', function () {
21-
$this->context->enter('test-block', 'ulid-123');
21+
$this->context->enter('test-block', 'uuid-123');
2222

2323
expect($this->context->isInside())->toBeTrue()
2424
->and($this->context->current())->toBe([
2525
'name' => 'test-block',
26-
'ulid' => 'ulid-123',
26+
'uuid' => 'uuid-123',
2727
]);
2828
});
2929

3030
it('clears context when exiting', function () {
31-
$this->context->enter('test-block', 'ulid-123');
31+
$this->context->enter('test-block', 'uuid-123');
3232
$this->context->exit();
3333

3434
expect($this->context->isInside())->toBeFalse()
3535
->and($this->context->current())->toBeNull();
3636
});
3737

3838
it('prevents nested controlled blocks', function () {
39-
$this->context->enter('outer-block', 'ulid-outer');
39+
$this->context->enter('outer-block', 'uuid-outer');
4040

41-
expect(fn () => $this->context->enter('inner-block', 'ulid-inner'))
41+
expect(fn () => $this->context->enter('inner-block', 'uuid-inner'))
4242
->toThrow(
4343
NestedControlledBlockException::class,
44-
"Nested Controlled block detected: attempted to start 'inner-block' while already in 'outer-block' (ULID: ulid-outer)."
44+
"Nested Controlled block detected: attempted to start 'inner-block' while already in 'outer-block' (uuid: uuid-outer)."
4545
);
4646
});
4747

4848
it('allows sequential blocks after exit', function () {
49-
$this->context->enter('first-block', 'ulid-first');
49+
$this->context->enter('first-block', 'uuid-first');
5050
$this->context->exit();
5151

5252
// Should not throw
53-
$this->context->enter('second-block', 'ulid-second');
53+
$this->context->enter('second-block', 'uuid-second');
5454

5555
expect($this->context->current())->toBe([
5656
'name' => 'second-block',
57-
'ulid' => 'ulid-second',
57+
'uuid' => 'uuid-second',
5858
]);
5959
});
6060

6161
it('handles multiple exit calls gracefully', function () {
62-
$this->context->enter('test-block', 'ulid-123');
62+
$this->context->enter('test-block', 'uuid-123');
6363
$this->context->exit();
6464
$this->context->exit(); // Should not cause errors
6565

0 commit comments

Comments
 (0)