Context   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 6
c 1
b 0
f 1
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaggageItem() 0 3 2
A withBaggageItem() 0 5 1
A getIterator() 0 3 1
1
<?php
2
/**
3
 * OpenTracing::Context
4
 * User: moyo
5
 * Date: 23/11/2017
6
 * Time: 3:31 PM
7
 */
8
9
namespace Carno\Tracing\Standard;
10
11
use OpenTracing\SpanContext;
12
use ArrayIterator;
13
use ArrayObject;
14
15
class Context extends ArrayObject implements SpanContext
16
{
17
    /**
18
     * @return ArrayIterator
19
     */
20
    public function getIterator() : ArrayIterator
21
    {
22
        return new ArrayIterator($this->getArrayCopy());
23
    }
24
25
    /**
26
     * @param string $key
27
     * @return string|null
28
     */
29
    public function getBaggageItem($key) : ?string
30
    {
31
        return $this->offsetExists($key) ? $this->offsetGet($key) : null;
32
    }
33
34
    /**
35
     * @param string $key
36
     * @param string $value
37
     * @return SpanContext
38
     */
39
    public function withBaggageItem($key, $value) : SpanContext
40
    {
41
        $new = clone $this;
42
        $new->offsetSet($key, $value);
43
        return $new;
44
    }
45
}
46