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

CompositeException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 3
b 0
f 0
dl 0
loc 26
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getFirstException() 0 3 1
A getPreviousExceptions() 0 3 1
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
    private array $rest;
19
20 3
    public function __construct(
21
        private Throwable $first,
22
        Throwable ...$rest,
23
    ) {
24 3
        $this->rest = $rest;
25 3
        parent::__construct($first->getMessage(), (int) $first->getCode(), $first);
26
    }
27
28 2
    public function getFirstException(): Throwable
29
    {
30 2
        return $this->first;
31
    }
32
33
    /**
34
     * @return Throwable[]
35
     */
36 2
    public function getPreviousExceptions(): array
37
    {
38 2
        return $this->rest;
39
    }
40
}
41