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

NullTracer::withContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 1
c 2
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\Core\Container;
8
use Spiral\Core\ContainerScope;
9
use Spiral\Core\InvokerInterface;
10
use Spiral\Core\ScopeInterface;
11
12
final class NullTracer implements TracerInterface
13
{
14
    public function __construct(
15
        private readonly ?ScopeInterface $scope = new Container(),
16
    ) {
17
    }
18
19
    public function trace(
20
        string $name,
21
        callable $callback,
22
        array $attributes = [],
23
        bool $scoped = false,
24
        bool $debug = false,
25
        ?TraceKind $traceKind = null,
26
        ?int $startTime = null
27
    ): mixed {
28
        $span = new Span($name);
29
30
        return $this->scope->runScope([
0 ignored issues
show
Bug introduced by
The method runScope() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        return $this->scope->/** @scrutinizer ignore-call */ runScope([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
            SpanInterface::class => $span,
32
        ], static fn (): mixed => ContainerScope::getContainer()->get(InvokerInterface::class)->invoke($callback));
33
    }
34
35
    public function withContext(?array $context): self
36
    {
37
        return $this;
38
    }
39
40
    public function getContext(): ?array
41
    {
42
        return null;
43
    }
44
}
45