Failed Conditions
Pull Request — develop (#3131)
by Michael
94:07 queued 29:00
created

NamedForeignKeyRequired::new()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
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