SelfDurationCalculator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 13 3
1
<?php
2
3
namespace ZoiloMora\ElasticAPM\Processor\MetricSetProcessor;
4
5
use ZoiloMora\ElasticAPM\Events\Span\Span as SpanEvent;
6
use ZoiloMora\ElasticAPM\Events\Transaction\Transaction as TransactionEvent;
7
8
final class SelfDurationCalculator
9
{
10
    /**
11
     * @param SpanEvent|TransactionEvent $event
12
     * @param SpanEvent[]|TransactionEvent[] $events
13
     *
14
     * @return double
15
     */
16 1
    public function execute($event, array $events)
17
    {
18 1
        $selfDuration = $event->duration();
19
20 1
        foreach ($events as $item) {
21 1
            if ($item instanceof TransactionEvent) {
22 1
                continue;
23
            }
24
25 1
            $selfDuration -= $item->duration();
26 1
        }
27
28 1
        return $selfDuration;
29
    }
30
}
31