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

SerializationFailed::new()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 3
crap 6
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