Failed Conditions
Push — master ( 01c22b...e42c1f )
by Marco
79:13 queued 10s
created

NamedForeignKeyRequired   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 9
dl 0
loc 12
rs 10
c 1
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
use function sprintf;
12
13
final class NamedForeignKeyRequired extends SchemaException
14
{
15
    public static function new(Table $localTable, ForeignKeyConstraint $foreignKey) : self
16
    {
17
        return new self(
18
            sprintf(
19
                'The performed schema operation on "%s" requires a named foreign key, ' .
20
                'but the given foreign key from (%s) onto foreign table "%s" (%s) is currently unnamed.',
21
                $localTable->getName(),
22
                implode(', ', $foreignKey->getColumns()),
23
                $foreignKey->getForeignTableName(),
24
                implode(', ', $foreignKey->getForeignColumns())
25
            )
26
        );
27
    }
28
}
29