Passed
Push — master ( e7208d...6b33a9 )
by Alec
02:04
created

CallerDataFormatter::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 19
nc 2
nop 1
dl 0
loc 24
ccs 17
cts 17
cp 1
crap 2
rs 9.6333
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
4
namespace AlecRabbit\Accessories\Caller;
5
6
use AlecRabbit\Accessories\Caller\Contracts\CallerDataFormatterInterface;
7
8
class CallerDataFormatter implements CallerDataFormatterInterface
9
{
10 4
    public function process(CallerData $data): string
11
    {
12 4
        $function = $data->getFunction();
13
        $lineAndFile =
14 4
            sprintf(
15 4
                '[%s:"%s"]',
16 4
                $data->getLine(),
17 4
                $data->getFile()
18
            );
19 4
        if (null !== $class = $data->getClass()) {
20
            return
21 3
                sprintf(
22 3
                    '%s%s%s %s',
23 3
                    $class,
24 3
                    $data->getType(),
25 3
                    $function,
26 3
                    $lineAndFile
27
                );
28
        }
29
        return
30 1
            sprintf(
31 1
                '%s %s',
32 1
                $function,
33 1
                $lineAndFile
34
            );
35
    }
36
}
37