Completed
Push — master ( eff795...9418cb )
by Oliver
08:18
created

NinjaMutexLockAdapter::isLocked()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Metabor;
4
5
use MetaborStd\Semaphore\LockAdapterInterface;
6
use NinjaMutex\Lock\LockInterface;
7
8
/**
9
 * @author Oliver Tischlinger
10
 */
11
class NinjaMutexLockAdapter implements LockAdapterInterface
12
{
13
    /**
14
     * @var LockInterface
15
     */
16
    private $ninjaMutexLock;
17
18
    /**
19
     * @var null|int
20
     */
21
    private $timeout;
22
23
    /**
24
     * @param LockInterface $ninjaMutexLock
25
     * @param null|int $timeout
26
     */
27
    public function __construct(LockInterface $ninjaMutexLock, $timeout = null)
28
    {
29
        $this->ninjaMutexLock = $ninjaMutexLock;
30
        $this->timeout = $timeout;
31
    }
32
33
    /**
34
     * @param string $resourceName
35
     * @return bool
36
     */
37
    public function acquireLock($resourceName)
38
    {
39
        return $this->ninjaMutexLock->acquireLock($resourceName, $this->timeout);
40
    }
41
42
    /**
43
     * @param string $resourceName
44
     * @return bool
45
     */
46
    public function releaseLock($resourceName)
47
    {
48
        return $this->ninjaMutexLock->releaseLock($resourceName);
49
    }
50
51
    /**
52
     * @param string $resourceName
53
     * @return bool
54
     */
55
    public function isLocked($resourceName)
56
    {
57
        return $this->ninjaMutexLock->isLocked($resourceName);
58
    }
59
}
60