Failed Conditions
Pull Request — master (#7210)
by Michael
17:55
created

EntityNotFound::fromClassNameAndIdentifier()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 2
nop 2
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 3
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Exception;
6
7
use function implode;
8
9
/**
10
 * Exception thrown when a Proxy fails to retrieve an Entity result.
11
 */
12
final class EntityNotFound extends \RuntimeException implements ORMException
13
{
14
    /**
15
     * Static constructor.
16
     *
17
     * @param string   $className
18
     * @param string[] $id
19
     *
20
     * @return self
21
     */
22 3
    public static function fromClassNameAndIdentifier($className, array $id)
23
    {
24 3
        $ids = [];
25
26 3
        foreach ($id as $key => $value) {
27 3
            $ids[] = $key . '(' . $value . ')';
28
        }
29
30 3
        return new self(
31 3
            'Entity of type \'' . $className . '\'' . ($ids ? ' for IDs ' . implode(', ', $ids) : '') . ' was not found'
32
        );
33
    }
34
}
35