Total Complexity | 4 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | final class ElasticApmTracerSingleton |
||
6 | { |
||
7 | /** |
||
8 | * @var ElasticApmTracer |
||
9 | */ |
||
10 | private static $instance = null; |
||
11 | |||
12 | /** |
||
13 | * @param ElasticApmTracer $instance |
||
14 | * |
||
15 | * @throws \Exception |
||
16 | */ |
||
17 | 2 | public static function inject(ElasticApmTracer $instance) |
|
18 | { |
||
19 | 2 | if (null !== self::$instance) { |
|
20 | 1 | throw new \Exception('Already an injected object, it cannot be replaced.'); |
|
21 | } |
||
22 | |||
23 | 2 | self::$instance = $instance; |
|
24 | 2 | } |
|
25 | |||
26 | /** |
||
27 | * @return ElasticApmTracer |
||
28 | * |
||
29 | * @throws \Exception |
||
30 | */ |
||
31 | 2 | public static function instance() |
|
38 | } |
||
39 | } |
||
40 |