SelfDurationCalculator::execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 13
ccs 8
cts 8
cp 1
crap 3
rs 10
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