Subversion-Projekte lars-tiefland.laravel_shop

Revision

Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Spatie\Backtrace;
4
 
5
class Frame
6
{
7
    /** @var string */
8
    public $file;
9
 
10
    /** @var int */
11
    public $lineNumber;
12
 
13
    /** @var array|null */
14
    public $arguments = null;
15
 
16
    /** @var bool */
17
    public $applicationFrame;
18
 
19
    /** @var string|null */
20
    public $method;
21
 
22
    /** @var string|null */
23
    public $class;
24
 
25
    public function __construct(
26
        string $file,
27
        int $lineNumber,
28
        ?array $arguments,
29
        string $method = null,
30
        string $class = null,
31
        bool $isApplicationFrame = false
32
    ) {
33
        $this->file = $file;
34
 
35
        $this->lineNumber = $lineNumber;
36
 
37
        $this->arguments = $arguments;
38
 
39
        $this->method = $method;
40
 
41
        $this->class = $class;
42
 
43
        $this->applicationFrame = $isApplicationFrame;
44
    }
45
 
46
    public function getSnippet(int $lineCount): array
47
    {
48
        return (new CodeSnippet())
49
            ->surroundingLine($this->lineNumber)
50
            ->snippetLineCount($lineCount)
51
            ->get($this->file);
52
    }
53
 
54
    public function getSnippetProperties(int $lineCount): array
55
    {
56
        $snippet = $this->getSnippet($lineCount);
57
 
58
        return array_map(function (int $lineNumber) use ($snippet) {
59
            return [
60
                'line_number' => $lineNumber,
61
                'text' => $snippet[$lineNumber],
62
            ];
63
        }, array_keys($snippet));
64
    }
65
}