These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Doctrine\ODM\MongoDB; |
||
6 | |||
7 | use Throwable; |
||
8 | use const E_USER_DEPRECATED; |
||
9 | use function json_encode; |
||
10 | use function sprintf; |
||
11 | use function trigger_error; |
||
12 | |||
13 | /** |
||
14 | * Class for exception when encountering proxy object that has |
||
15 | * an identifier that does not exist in the database. |
||
16 | * |
||
17 | * @final |
||
18 | */ |
||
19 | class DocumentNotFoundException extends MongoDBException |
||
20 | { |
||
21 | 8 | public function __construct($message = '', $code = 0, ?Throwable $previous = null) |
|
22 | { |
||
23 | 8 | if (self::class !== static::class) { |
|
24 | @trigger_error(sprintf('The class "%s" extends "%s" which will be final in MongoDB ODM 2.0.', static::class, self::class), E_USER_DEPRECATED); |
||
0 ignored issues
–
show
|
|||
25 | } |
||
26 | 8 | parent::__construct($message, $code, $previous); |
|
27 | 8 | } |
|
28 | |||
29 | 8 | public static function documentNotFound(string $className, $identifier) : self |
|
30 | { |
||
31 | 8 | return new self(sprintf( |
|
32 | 8 | 'The "%s" document with identifier %s could not be found.', |
|
33 | 8 | $className, |
|
34 | 8 | json_encode($identifier) |
|
35 | )); |
||
36 | } |
||
37 | } |
||
38 |
If you suppress an error, we recommend checking for the error condition explicitly: