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

Stacktrace::getFrames()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 11
ccs 0
cts 7
cp 0
crap 6
rs 10
c 0
b 0
f 0
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