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

ObjectMappingFailed::tryingToMapItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 2
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
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