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

Caller::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 0
cp 0
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
    // @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