Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
WrappedErrorTrace
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
6
100.00% covered (success)
100.00%
1 / 1
 __construct
n/a
0 / 0
n/a
0 / 0
1
 jsonSerialize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __get
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFileContents
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2namespace Apie\HtmlBuilders\ErrorHandler;
3
4use Apie\Core\Attributes\Description;
5use Apie\Core\Attributes\Optional;
6use Apie\Core\ValueObjects\CompositeValueObject;
7use Apie\Core\ValueObjects\Interfaces\ValueObjectInterface;
8use JsonSerializable;
9
10#[Description('Represents a single line in an error stacktrace often used in development mode only')]
11final class WrappedErrorTrace implements ValueObjectInterface, JsonSerializable
12{
13    use CompositeValueObject;
14
15    #[Optional]
16    private string $file;
17
18    #[Optional]
19    private int $line;
20
21    #[Optional]
22    private string $function;
23
24    #[Optional]
25    private string $class;
26
27    #[Optional]
28    private string $type;
29
30    /**
31     * @codeCoverageIgnore
32     */
33    private function __construct()
34    {
35    }
36
37    /**
38     * @return array<string, int|string|array<int,mixed>>
39     */
40    public function jsonSerialize(): array
41    {
42        return $this->toNative();
43    }
44
45    public function __get(string $key): mixed
46    {
47        return $this->$key;
48    }
49
50    public function getFileContents(): ?string
51    {
52        if (isset($this->file) && is_readable($this->file)) {
53            return file_get_contents($this->file);
54        }
55
56        return null;
57    }
58}