Passed
Push — develop ( 211c11...b276cd )
by Baptiste
01:42
created

SchemaNotParseable::rethrow()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 1
nop 1
dl 0
loc 17
ccs 12
cts 12
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Config\Exception;
5
6
use Innmind\Immutable\Sequence;
7
8
final class SchemaNotParseable extends DomainException
9
{
10 3
    public static function rethrow(self $exception): self
11
    {
12 3
        $original = $exception;
13 3
        $messages = new Sequence;
14
15
        do {
16 3
            $messages = $messages->add($exception->getMessage());
17 3
        } while ($exception = $exception->getPrevious());
18
19 3
        throw new self(
20
            (string) $messages
21 3
                ->filter(static function(string $message): bool {
22 3
                    return $message !== '';
23 3
                })
24 3
                ->join('.'),
25 3
            0,
26 3
            $original
27
        );
28
    }
29
}
30