Failed Conditions
Pull Request — develop (#3525)
by Jonathan
09:58
created

NamedForeignKeyRequired::new()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 10
c 0
b 0
f 0
ccs 0
cts 8
cp 0
rs 9.9666
cc 1
nc 1
nop 2
crap 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