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

NamedForeignKeyRequired::new()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 10
rs 9.9666
c 1
b 0
f 0
cc 1
nc 1
nop 2
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