Completed
Push — master ( 07356a...ec2855 )
by Oliver
05:36
created

NinjaMutexLockAdapter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 49
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A acquireLock() 0 4 1
A releaseLock() 0 4 1
A isLocked() 0 4 1
1
<?php
2
3
namespace Metabor\Adapter;
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