![]() Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : fdshops ( 1003) PHP Version : 8.2.21 Disable Function : NONE Directory : /home/fdshops/public_html/vendor/spatie/laravel-activitylog/src/ |
<?php namespace Spatie\Activitylog; use Closure; use Ramsey\Uuid\Uuid; class LogBatch { public ?string $uuid = null; public int $transactions = 0; protected function generateUuid(): string { return Uuid::uuid4()->toString(); } public function getUuid(): ?string { return $this->uuid; } public function setBatch(string $uuid): void { $this->uuid = $uuid; $this->transactions = 1; } public function withinBatch(Closure $callback): mixed { $this->startBatch(); $result = $callback($this->getUuid()); $this->endBatch(); return $result; } public function startBatch(): void { if (! $this->isOpen()) { $this->uuid = $this->generateUuid(); } $this->transactions++; } public function isOpen(): bool { return $this->transactions > 0; } public function endBatch(): void { $this->transactions = max(0, $this->transactions - 1); if ($this->transactions === 0) { $this->uuid = null; } } }