blob: 2dd2ba9bd7fbe56ce003a194e67b55d53e71bac3 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace LdapRecord\Models;
4
5use LdapRecord\LdapRecordException;
6
7class ModelDoesNotExistException extends LdapRecordException
8{
9 /**
10 * The class name of the model that does not exist.
11 *
12 * @var Model
13 */
14 protected $model;
15
16 /**
17 * Create a new exception for the given model.
18 *
19 * @param Model $model
20 *
21 * @return ModelDoesNotExistException
22 */
23 public static function forModel(Model $model)
24 {
25 return (new static())->setModel($model);
26 }
27
28 /**
29 * Set the model that does not exist.
30 *
31 * @param Model $model
32 *
33 * @return ModelDoesNotExistException
34 */
35 public function setModel(Model $model)
36 {
37 $this->model = $model;
38
39 $class = get_class($model);
40
41 $this->message = "Model [{$class}] does not exist.";
42
43 return $this;
44 }
45}