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

CallFrame   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 10
c 2
b 1
f 1
dl 0
loc 32
rs 10
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFullyQualifiedFunctionName() 0 6 2
A __construct() 0 6 1
A getLineno() 0 6 2
A getOpcodeName() 0 6 2
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