Total Complexity | 10 |
Total Lines | 102 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
9 | class CallerData implements CallerDataInterface, CallerConstants |
||
10 | { |
||
11 | /** @var string */ |
||
12 | protected $function; |
||
13 | |||
14 | /** @var int|null */ |
||
15 | protected $line; |
||
16 | |||
17 | /** @var string|null */ |
||
18 | protected $file; |
||
19 | |||
20 | /** @var string|null */ |
||
21 | protected $class; |
||
22 | |||
23 | /** @var object|null */ |
||
24 | protected $object; |
||
25 | |||
26 | /** @var string|null */ |
||
27 | protected $type; |
||
28 | |||
29 | /** @var array|null */ |
||
30 | protected $args; |
||
31 | |||
32 | 4 | public function __construct( |
|
33 | array $caller |
||
34 | ) { |
||
35 | $this->function = $caller[self::FUNCTION]; |
||
36 | 4 | $this->parse($caller); |
|
37 | 4 | } |
|
38 | |||
39 | 4 | protected function parse(array $caller): void |
|
40 | { |
||
41 | 4 | $this->line = $caller[self::LINE] ?? null; |
|
42 | 4 | $this->file = $caller[self::FILE] ?? null; |
|
43 | 4 | $this->class = $caller[self::CLS] ?? null; |
|
44 | 4 | $this->object = $caller[self::OBJECT] ?? null; |
|
45 | 4 | $this->type = $caller[self::TYPE] ?? null; |
|
46 | 4 | $this->args = $caller[self::ARGS] ?? null; |
|
47 | 4 | } |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 4 | public function __toString(): string |
|
53 | { |
||
54 | 4 | return Caller::getFormatter()->process($this); |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 4 | public function getFunction(): string |
|
61 | { |
||
62 | 4 | return $this->function; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | 4 | public function getLine(): ?int |
|
69 | { |
||
70 | 4 | return $this->line; |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 4 | public function getFile(): ?string |
|
77 | { |
||
78 | 4 | return $this->file; |
|
79 | } |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | 4 | public function getClass(): ?string |
|
87 | } |
||
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | 3 | public function getObject(): ?object |
|
93 | { |
||
94 | 3 | return $this->object; |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | 3 | public function getType(): ?string |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | 3 | public function getArgs(): ?array |
|
111 | } |
||
112 | } |
||
113 |