Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
AbstractDomainException
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getContext
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10namespace Phexium\Domain\Exception;
11
12use DomainException;
13use Override;
14use Throwable;
15
16abstract class AbstractDomainException extends DomainException implements DomainExceptionInterface
17{
18    public function __construct(
19        string $message = '',
20        private readonly array $context = [],
21        int $code = 0,
22        ?Throwable $previous = null,
23    ) {
24        parent::__construct($message, $code, $previous);
25    }
26
27    #[Override]
28    public function getContext(): array
29    {
30        return $this->context;
31    }
32
33    #[Override]
34    public function toArray(): array
35    {
36        return [
37            'message' => $this->getMessage(),
38            'context' => $this->getContext(),
39            'code' => $this->getCode(),
40            'file' => $this->getFile(),
41            'line' => $this->getLine(),
42        ];
43    }
44}