Failed Conditions
Pull Request — develop (#3131)
by Michael
60:38
created

ValueNotConvertible   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 9
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A new() 0 7 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 sprintf;
9
use function strlen;
10
use function substr;
11
12
/**
13
 * Thrown when a Database to Doctrine Type Conversion fails.
14
 */
15
final class ValueNotConvertible extends ConversionException implements TypesException
16
{
17
    public static function new(string $value, string $toType) : self
18
    {
19
        return new self(
20
            sprintf(
21
                'Could not convert database value "%s" to Doctrine Type %s',
22
                strlen($value) > 32 ? substr($value, 0, 20) . '...' : $value,
23
                $toType
24
            )
25
        );
26
    }
27
}
28