Passed
Push — master ( e7f49b...05f9be )
by Alec
01:39
created

Caller::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 9
ccs 7
cts 7
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlecRabbit\Accessories;
6
7
class Caller
8
{
9
    /**
10
     * Static class. Private Constructor.
11
     */
12
    // @codeCoverageIgnoreStart
13
    private function __construct()
14
    {
15
    }
16
17
    // @codeCoverageIgnoreEnd
18
19 1
    public static function get(int $depth = 2): string
20
    {
21 1
        $caller = debug_backtrace()[$depth];
22 1
        $type = $caller['type'] ?? '';
23 1
        $function = $caller['function'] . '()';
24
        return
25 1
            isset($caller['class']) ?
26 1
                $caller['class'] . $type . $function :
27 1
                $function;
28
    }
29
}
30