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

src/Stacktrace.php (1 issue)

Labels
Severity
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
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