Passed
Pull Request — master (#83)
by Бабичев
07:23
created

EmptyLock::release()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 1
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Bavix\Wallet\Objects;
4
5
use Illuminate\Contracts\Cache\Lock;
6
use Illuminate\Support\Str;
7
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 53
    public function get($callback = null)
18
    {
19 53
        if ($callback === null) {
20
            return null;
21
        }
22
23 53
        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
64
    {
65
        // force lock release
66
    }
67
68
}
69