Passed
Pull Request — master (#87)
by Dmitriy
02:27
created

CompositeException::getFirstException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ErrorHandler;
6
7
use Exception;
8
use Throwable;
9
10
/**
11
 * Aggregate multiple exceptions into one.
12
 */
13
final class CompositeException extends Exception
14
{
15
    /**
16
     * @var Throwable[]
17
     */
18
    public array $rest;
19
20 1
    public function __construct(
21
        private Throwable $first,
22
        Throwable ...$rest,
23
    ) {
24 1
        $this->rest = $rest;
25
        /**
26
         * @psalm-suppress PossiblyInvalidArgument
27
         */
28 1
        parent::__construct($first->getMessage(), $first->getCode(), $first);
29
    }
30
31
    public function getFirstException(): Throwable
32
    {
33
        return $this->first;
34
    }
35
36
    /**
37
     * @return Throwable[]
38
     */
39
    public function getPreviousExceptions(): array
40
    {
41
        return $this->rest;
42
    }
43
}
44