Passed
Push — master ( dc95cb...e7f49b )
by Alec
01:45
created

Caller::method()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3.0067

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 4
nop 1
dl 0
loc 15
ccs 10
cts 11
cp 0.9091
crap 3.0067
rs 9.9
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
    // @codeCoverageIgnoreEnd
17
18 1
    public static function method(int $depth = 3): string
19
    {
20 1
        $caller = static::get($depth);
21 1
        $r = '';
22 1
        $function = $caller['function'] . '()';
23 1
        if (isset($caller['class'])) {
24 1
            $type = $caller['type'] ?? '';
25 1
            $r .= $caller['class'] . $type . $function;
26
        } else {
27
            $r .= $function;
28
        }
29 1
        if (isset($caller['object'])) {
30 1
            $r .= ' (' . \get_class($caller['object']) . ')';
31
        }
32 1
        return $r;
33
    }
34
35 1
    public static function get(int $depth = 2): array
36
    {
37
//        dump(debug_backtrace());
38
        return
39 1
            debug_backtrace()[$depth];
40
    }
41
}
42