ProxyMappingFailure::encountered()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 12
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 ProxyMappingFailure extends RuntimeException implements MappingFailure
12
{
13
    public static function encountered(
14
        Mapping $mapping,
15
        Throwable $exception
16
    ): MappingFailure {
17
        return new self(
18
            sprintf(
19
                'Proxy production for in the `%s` property failed: %s',
20
                $mapping->name(),
21
                $exception->getMessage()
22
            ),
23
            0,
24
            $exception
25
        );
26
    }
27
}