NamedForeignKeyRequired   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

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
use function sprintf;
12
13
/**
14
 * @psalm-immutable
15
 */
16
final class NamedForeignKeyRequired extends SchemaException
17
{
18
    public static function new(Table $localTable, ForeignKeyConstraint $foreignKey) : self
19
    {
20
        return new self(
21
            sprintf(
22
                'The performed schema operation on "%s" requires a named foreign key, ' .
23
                'but the given foreign key from (%s) onto foreign table "%s" (%s) is currently unnamed.',
24
                $localTable->getName(),
25
                implode(', ', $foreignKey->getColumns()),
26
                $foreignKey->getForeignTableName(),
27
                implode(', ', $foreignKey->getForeignColumns())
28
            )
29
        );
30
    }
31
}
32