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

ValueNotConvertible::new()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 1
nop 2
crap 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
/**
10
 * Thrown when a Database to Doctrine Type Conversion fails.
11
 */
12
final class ValueNotConvertible extends ConversionException implements TypesException
13
{
14 210
    public static function new(string $value, string $toType) : self
15
    {
16 210
        return new self(
17 210
            sprintf(
18 210
                'Could not convert database value "%s" to Doctrine Type %s',
19 210
                strlen($value) > 32 ? substr($value, 0, 20) . '...' : $value,
20 210
                $toType
21
            )
22
        );
23
    }
24
}
25