Passed
Push — exceptions ( 7fc4df...ac8412 )
by Michael
15:33
created

NamedForeignKeyRequired   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 12
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A new() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Schema\Exception;
6
7
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
8
use Doctrine\DBAL\Schema\SchemaException;
9
use Doctrine\DBAL\Schema\Table;
10
use function implode;
11
12
final class NamedForeignKeyRequired extends SchemaException
13
{
14
    public static function new(Table $localTable, ForeignKeyConstraint $foreignKey) : self
15
    {
16
        return new self(
17
            sprintf(
18
            "The performed schema operation on %s requires a named foreign key, " .
19
            "but the given foreign key from (%s) onto foreign table '%s' (%s) is currently unnamed.",
20
                $localTable->getName(),
21
                implode(', ', $foreignKey->getColumns()),
22
                $foreignKey->getForeignTableName(),
23
                implode(', ', $foreignKey->getForeignColumns())
24
            )
25
        );
26
    }
27
}
28