Passed
Pull Request — master (#31)
by Alexander
02:09
created

MutexFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
ccs 0
cts 5
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A createAndAcquire() 0 7 2
1
<?php
2
3
namespace Yiisoft\Mutex;
4
5
use RuntimeException;
6
7
abstract class MutexFactory implements MutexFactoryInterface
8
{
9
    final public function createAndAcquire(string $name): MutexInterface
10
    {
11
        $mutex = $this->create($name);
12
        if (!$mutex->acquire()) {
13
            throw new RuntimeException("Unable to acquire mutex \"$name\".");
14
        }
15
        return $mutex;
16
    }
17
}
18