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

Caller   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A get() 0 9 2
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