Total Complexity | 7 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | final class AtomicMutableWrapper implements MutableMetricInterface |
||
11 | { |
||
12 | /** @var EntityManagerInterface */ |
||
13 | private $manager; |
||
14 | /** @var MutableMetricInterface */ |
||
15 | private $metric; |
||
16 | |||
17 | 3 | public function __construct(EntityManagerInterface $manager, MutableMetricInterface $metric) |
|
18 | { |
||
19 | 3 | $this->manager = $manager; |
|
20 | 3 | $this->metric = $metric; |
|
21 | 3 | } |
|
22 | |||
23 | /** {@inheritdoc} */ |
||
24 | 1 | public function adjust(float $delta): void |
|
25 | { |
||
26 | 1 | $this->executeWithLock( |
|
27 | function () use ($delta) { |
||
28 | 1 | $this->metric->adjust($delta); |
|
29 | 1 | } |
|
30 | ); |
||
31 | 1 | } |
|
32 | |||
33 | /** {@inheritdoc} */ |
||
34 | 1 | public function setValue(float $value): void |
|
35 | { |
||
36 | 1 | $this->executeWithLock( |
|
37 | function () use ($value) { |
||
38 | 1 | $this->metric->setValue($value); |
|
39 | 1 | } |
|
40 | ); |
||
41 | 1 | } |
|
42 | |||
43 | /** {@inheritdoc} */ |
||
44 | 1 | public function getName(): string |
|
45 | { |
||
46 | 1 | return $this->metric->getName(); |
|
47 | } |
||
48 | |||
49 | /** {@inheritdoc} */ |
||
50 | 1 | public function resolve(): float |
|
53 | } |
||
54 | |||
55 | /** {@inheritdoc} */ |
||
56 | 1 | public function getTags(): array |
|
59 | } |
||
60 | |||
61 | 2 | private function executeWithLock(callable $fn): void |
|
62 | { |
||
72 | 2 | } |
|
73 | ); |
||
76 |