Test Failed
Push — master ( 90252a...135589 )
by Waaaaaaaaaa
02:31
created

Stacktrace   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 48
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getFrames() 0 11 2
A getTrace() 0 12 3
1
<?php declare(strict_types=1);
2
3
namespace Logfile;
4
5
use Throwable;
6
7
class Stacktrace
8
{
9
    use PathTrait;
0 ignored issues
show
Bug introduced by
The type Logfile\PathTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
    /**
12
     * @var Throwable
13
     */
14
    protected $exception;
15
16
    /**
17
     * @param Throwable
18
     */
19
    public function __construct(Throwable $exception)
20
    {
21
        $this->exception = $exception;
22
    }
23
24
    /**
25
     * @return array
26
     */
27
    public function getTrace(): array
28
    {
29
        $frames = $this->exception->getTrace();
30
31
        if (!isset($frames[0]['file']) || $frames[0]['file'] !== $this->exception->getFile()) {
32
            array_unshift($frames, [
33
                'file' => $this->exception->getFile(),
34
                'line' => $this->exception->getLine(),
35
            ]);
36
        }
37
38
        return $frames;
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function getFrames(): array
45
    {
46
        $frames = [];
47
48
        foreach ($this->getTrace() as $params) {
49
            $frame = Frame::create($params);
50
            $frame->setPath($this->getPath());
51
            $frames[] = $frame->toArray();
52
        }
53
54
        return $frames;
55
    }
56
}
57