Total Complexity | 5 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 75% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class LockService |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @param object $self |
||
15 | * @param string $name |
||
16 | * @param \Closure $closure |
||
17 | * @return mixed |
||
18 | */ |
||
19 | 46 | public function lock($self, string $name, \Closure $closure) |
|
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param object $self |
||
27 | * @param \Closure $closure |
||
28 | * @return \Closure |
||
29 | */ |
||
30 | 46 | protected function bindTo($self, \Closure $closure): \Closure |
|
31 | { |
||
32 | try { |
||
33 | 46 | return $closure->bindTo($self); |
|
34 | } catch (\Throwable $throwable) { |
||
35 | return $closure; |
||
36 | } |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param string $name |
||
41 | * @param int $seconds |
||
42 | * @return Lock |
||
43 | */ |
||
44 | 46 | protected function lockProvider(string $name, int $seconds): Lock |
|
56 | } |
||
57 | |||
59 |