Frame   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFullMethod() 0 10 2
A getFile() 0 4 1
A __construct() 0 14 1
A toArray() 0 14 1
1
<?php
2
3
namespace Facade\FlareClient;
4
5
use Facade\FlareClient\Stacktrace\Codesnippet;
6
7
class Frame
8
{
9
    /** @var string */
10
    private $file;
11
12
    /** @var int */
13
    private $lineNumber;
14
15
    /** @var string */
16
    private $method;
17
18
    /** @var string */
19
    private $class;
20
21
    public function __construct(
22
        string $file,
23
        int $lineNumber,
24
        string $method = null,
25
        string $class = null
26
    ) {
27
        $this->file = $file;
28
29
        $this->lineNumber = $lineNumber;
30
31
        $this->method = $method;
32
33
        $this->class = $class;
34
    }
35
36
    public function toArray(): array
37
    {
38
        $codeSnippet = (new Codesnippet())
39
            ->snippetLineCount(9)
40
            ->surroundingLine($this->lineNumber)
41
            ->get($this->file);
42
43
        return [
44
            'line_number' => $this->lineNumber,
45
            'method' => $this->getFullMethod(),
46
            'code_snippet' => $codeSnippet,
47
            'file' => $this->file,
48
        ];
49
    }
50
51
    private function getFullMethod(): string
52
    {
53
        $method = $this->method;
54
55
        if ($class = $this->class ?? false) {
56
            $method = "{$class}::{$method}";
57
        }
58
59
        return $method;
60
    }
61
62
    public function getFile(): string
63
    {
64
        return $this->file;
65
    }
66
}
67