Failed Conditions
Push — master ( 01c22b...e42c1f )
by Marco
79:13 queued 10s
created

SerializationFailed   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
dl 0
loc 15
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A new() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Types\Exception;
6
7
use Doctrine\DBAL\Types\ConversionException;
8
use function get_class;
9
use function gettype;
10
use function is_object;
11
use function sprintf;
12
13
final class SerializationFailed extends ConversionException implements TypesException
14
{
15
    /**
16
     * @param mixed $value
17
     */
18
    public static function new($value, string $format, string $error) : self
19
    {
20
        $actualType = is_object($value) ? get_class($value) : gettype($value);
21
22
        return new self(
23
            sprintf(
24
                'Could not convert PHP type "%s" to "%s". An error was triggered by the serialization: %s',
25
                $actualType,
26
                $format,
27
                $error
28
            )
29
        );
30
    }
31
}
32