Passed
Push — master ( 01c6a8...5a4258 )
by Jesse
09:00
created

CollectionMappingFailure::encountered()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 9
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Hydration\Mapping\Relation;
4
5
use RuntimeException;
6
use Stratadox\HydrationMapping\Mapping;
7
use Stratadox\HydrationMapping\MappingFailure;
8
use Throwable;
9
use function sprintf;
10
11
final class CollectionMappingFailure extends RuntimeException implements MappingFailure
12
{
13
    public static function encountered(
14
        Mapping $mapping,
15
        Throwable $exception
16
    ): MappingFailure {
17
        return new self(sprintf(
18
            'Failed to map the collection in the `%s` property: %s',
19
            $mapping->name(),
20
            $exception->getMessage()
21
        ), 0, $exception);
22
    }
23
}
24