forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntityNotFoundException.php
50 lines (42 loc) · 1.11 KB
/
EntityNotFoundException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
declare(strict_types=1);
namespace Doctrine\ORM;
use Doctrine\ORM\Exception\ORMException;
use function implode;
use function sprintf;
/**
* Exception thrown when a Proxy fails to retrieve an Entity result.
*/
class EntityNotFoundException extends ORMException
{
/**
* Static constructor.
*
* @param string $className
* @param string[] $id
*
* @return self
*/
public static function fromClassNameAndIdentifier($className, array $id)
{
$ids = [];
foreach ($id as $key => $value) {
$ids[] = $key . '(' . $value . ')';
}
return new self(
'Entity of type \'' . $className . '\'' . ($ids ? ' for IDs ' . implode(', ', $ids) : '') . ' was not found'
);
}
/**
* Instance for which no identifier can be found
*
* @psalm-param class-string $className
*/
public static function noIdentifierFound(string $className): self
{
return new self(sprintf(
'Unable to find "%s" entity identifier associated with the UnitOfWork',
$className
));
}
}