Completed
Push — master ( cd03ce...a0b884 )
by Jesse
02:19
created

ObjectMappingFailed   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A tryingToMapItem() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stratadox\Hydration\Mapping\Property\Relationship;
6
7
use ReflectionClass;
8
use RuntimeException;
9
use function sprintf;
10
use Stratadox\Hydration\MapsProperty;
11
use Stratadox\Hydration\UnmappableInput;
12
use Throwable;
13
14
final class ObjectMappingFailed extends RuntimeException implements UnmappableInput
15
{
16
    public static function tryingToMapItem(
17
        MapsProperty $mapping,
18
        Throwable $exception
19
    ) : self
20
    {
21
        return new self(
22
            sprintf(
23
                'Failed to map the %s relation of the `%s` property: %s',
24
                (new ReflectionClass($mapping))->getShortName(),
25
                $mapping->name(),
26
                $exception->getMessage()
27
            ),
28
            0,
29
            $exception
30
        );
31
    }
32
}
33