| Total Complexity | 6 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 7 | class SpanContext |
||
| 8 | { |
||
| 9 | private $traceId; |
||
| 10 | private $spanId; |
||
| 11 | |||
| 12 | 13 | public static function generate() |
|
| 13 | { |
||
| 14 | 13 | return self::fork(bin2hex(random_bytes(16))); |
|
| 15 | } |
||
| 16 | |||
| 17 | 13 | public static function fork(string $traceId) |
|
| 18 | { |
||
| 19 | 13 | return self::restore($traceId, bin2hex(random_bytes(8))); |
|
| 20 | } |
||
| 21 | |||
| 22 | 13 | public static function restore(string $traceId, string $spanId) |
|
| 23 | { |
||
| 24 | 13 | return new self($traceId, $spanId); |
|
| 25 | } |
||
| 26 | |||
| 27 | 13 | public function __construct(string $traceId, string $spanId) |
|
| 28 | { |
||
| 29 | 13 | $this->traceId = $traceId; |
|
| 30 | 13 | $this->spanId = $spanId; |
|
| 31 | 13 | } |
|
| 32 | |||
| 33 | 11 | public function getTraceId(): string |
|
| 36 | } |
||
| 37 | |||
| 38 | 5 | public function getSpanId(): string |
|
| 41 | } |
||
| 42 | } |
||
| 43 |