Lines 100.00% 1 / 1
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
NoopLock 100.00% 1 / 1 100.00% 1 / 1 1 100.00% 1 / 1
 withLock 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace BlueprintAU\Radiant\Database\Locks;
6
7/**
8 * The default {@see Lock}: takes no lock and documents why.
9 *
10 * Used when the host has not chosen a locking strategy. Running
11 * serialized-sensitive work (e.g. the schema `diff → apply` loop) without a
12 * cross-process lock is safe ONLY for single-instance deployments — two
13 * concurrent instances race to destructive operations. When a host's
14 * deployment can overlap, it must supply a real adapter
15 * (see {@see \BlueprintAU\Radiant\Database\Locks\SqliteLock}
16 * and siblings) or its own implementation.
17 */
18final class NoopLock implements Lock
19{
20    /**
21     * Run the callback immediately — no lock is taken.
22     *
23     * @template TReturn
24     *
25     * @param  callable(): TReturn  $callback
26     * @param  string  $name  Ignored.
27     * @return TReturn
28     * @throws \Throwable
29     */
30    #[\Override]
31    public function withLock(callable $callback, string $name): mixed
32    {
33        return $callback();
34    }
35}