Passed
Push — master ( 31e895...a7c06d )
by Shinji
02:24 queued 52s
created

CallFrame::getOpcodeName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-profiler package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpProfiler\Lib\PhpProcessReader;
15
16
use PhpProfiler\Lib\PhpInternals\Types\Zend\Opline;
17
18
/** @psalm-immutable */
19
final class CallFrame
20
{
21
    public function __construct(
22
        public string $class_name,
23
        public string $function_name,
24
        public string $file_name,
25
        public ?Opline $opline
26
    ) {
27
    }
28
29
    public function getFullyQualifiedFunctionName(): string
30
    {
31
        if ($this->class_name === '') {
32
            return $this->function_name;
33
        }
34
        return "{$this->class_name}::{$this->function_name}";
35
    }
36
37
    public function getLineno(): int
38
    {
39
        if (is_null($this->opline)) {
40
            return -1;
41
        }
42
        return $this->opline->lineno;
43
    }
44
45
    public function getOpcodeName(): string
46
    {
47
        if (is_null($this->opline)) {
48
            return '';
49
        }
50
        return $this->opline->opcode->getName();
51
    }
52
}
53