Passed
Pull Request — master (#816)
by butschster
06:49
created

NullTracer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
dl 0
loc 27
rs 10
c 2
b 0
f 0
ccs 8
cts 8
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getContext() 0 3 1
A trace() 0 15 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Telemetry;
6
7
use Spiral\Core\Container;
8
use Spiral\Core\InvokerInterface;
9
use Spiral\Core\ScopeInterface;
10
11
final class NullTracer implements TracerInterface
12
{
13 434
    public function __construct(
14
        private readonly ?ScopeInterface $scope = new Container(),
15
    ) {
16
    }
17
18 146
    public function trace(
19
        string $name,
20
        callable $callback,
21
        array $attributes = [],
22
        bool $scoped = false,
23
        bool $debug = false,
24
        ?TraceKind $traceKind = null,
25
        ?int $startTime = null
26
    ): mixed {
27 146
        $span = new Span($name);
28 146
        $span->setAttributes($attributes);
29
30 146
        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 146
        ], static fn (InvokerInterface $invoker): mixed => $invoker->invoke($callback));
33
    }
34
35 94
    public function getContext(): array
36
    {
37 94
        return [];
38
    }
39
}
40