Failed Conditions
Push — exceptions ( 64d080...7fc4df )
by Michael
15:07
created

SerializationFailed   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 15
ccs 0
cts 9
cp 0
rs 10
c 0
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
9
final class SerializationFailed extends ConversionException implements TypesException
10
{
11
    /**
12
     * @param mixed $value
13
     */
14
    public static function new($value, string $format, string $error) : self
15
    {
16
        $actualType = is_object($value) ? get_class($value) : gettype($value);
17
18
        return new self(
19
            sprintf(
20
                "Could not convert PHP type '%s' to '%s', as an '%s' error was triggered by the serialization",
21
                $actualType,
22
                $format,
23
                $error
24
            )
25
        );
26
    }
27
}
28