| Total Complexity | 6 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class EmptyLock implements Lock |
||
| 9 | { |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Attempt to acquire the lock. |
||
| 13 | * |
||
| 14 | * @param callable|null $callback |
||
| 15 | * @return mixed |
||
| 16 | */ |
||
| 17 | public function get($callback = null) |
||
| 18 | { |
||
| 19 | if ($callback === null) { |
||
| 20 | return null; |
||
| 21 | } |
||
| 22 | |||
| 23 | return $callback(); |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Attempt to acquire the lock for the given number of seconds. |
||
| 28 | * |
||
| 29 | * @param int $seconds |
||
| 30 | * @param callable|null $callback |
||
| 31 | * @return bool |
||
| 32 | */ |
||
| 33 | public function block($seconds, $callback = null): bool |
||
| 34 | { |
||
| 35 | return true; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Release the lock. |
||
| 40 | * |
||
| 41 | * @return void |
||
| 42 | */ |
||
| 43 | public function release(): void |
||
| 44 | { |
||
| 45 | // lock release |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Returns the current owner of the lock. |
||
| 50 | * |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | public function owner(): string |
||
| 54 | { |
||
| 55 | return Str::random(); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Releases this lock in disregard of ownership. |
||
| 60 | * |
||
| 61 | * @return void |
||
| 62 | */ |
||
| 63 | public function forceRelease(): void |
||
| 65 | // force lock release |
||
| 66 | } |
||
| 67 | |||
| 68 | } |
||
| 69 |