HEX
Server: LiteSpeed
System: Linux sv4.hami.host 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User: armgroup (1008)
PHP: 8.2.32
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, mail, socket_create, socket_create_listen, socket_create_pair, link, dl, openlog, syslog, stream_socket_server, curl_multi_init
Upload Files
File: /home/armgroup/libs/vendor/spatie/laravel-activitylog/src/LogBatch.php
<?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;
        }
    }
}