Test Failed
Pull Request — master (#816)
by butschster
06:13 queued 32s
created

Span::hasAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Telemetry;
6
7
use Spiral\Telemetry\Span\Status;
8
9
class Span implements SpanInterface
10
{
11
    private ?Status $status = null;
12
13
    public function __construct(
14
        private string $name,
15
        private array $attributes = []
16
    ) {
17
    }
18
19
    public function getName(): string
20
    {
21
        return $this->name;
22
    }
23
24
    public function updateName(string $name): self
25
    {
26
        $this->name = $name;
27
28
        return $this;
29
    }
30
31
    public function getAttributes(): array
32
    {
33
        return $this->attributes;
34
    }
35
36
    public function setAttributes(array $attributes): self
37
    {
38
        $this->attributes = $attributes;
39
40
        return $this;
41
    }
42
43
    public function setAttribute(string $name, mixed $value): self
44
    {
45
        $this->attributes[$name] = $value;
46
47
        return $this;
48
    }
49
50
    public function hasAttribute(string $name): bool
51
    {
52
        return isset($this->attributes[$name]);
53
    }
54
55
    public function getAttribute(string $name): mixed
56
    {
57
        return $this->attributes[$name];
58
    }
59
60
    public function setStatus(string $code, string $description = null): self
61
    {
62
        $this->status = new Status($code, $description);
63
64
        return $this;
65
    }
66
67
    public function getStatus(): ?Status
68
    {
69
        return $this->status;
70
    }
71
}
72