Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 4.4609 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
41 | 7 | public function transaction(Client $predis, string $key, int $ttl, \Closure $closure) |
|
42 | { |
||
43 | 7 | $this->lock($predis, $key, $ttl); |
|
44 | try { |
||
45 | 7 | $res = $closure(); |
|
46 | } catch (\Exception $e) { |
||
47 | $this->unlock($predis, $key); |
||
48 | throw $e; |
||
49 | } catch (\Throwable $e) { |
||
50 | $this->unlock($predis, $key); |
||
51 | throw $e; |
||
52 | } |
||
53 | // Unlock in correct flow. |
||
54 | 7 | $this->unlock($predis, $key); |
|
55 | |||
56 | 7 | return $res; |
|
57 | } |
||
59 |