| 1 |
<?php |
| 2 |
|
| 3 |
namespace ipl\Orm\Exception; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
use ipl\Orm\Model; |
| 7 |
|
| 8 |
class InvalidColumnException extends Exception |
| 9 |
{ |
| 10 |
/** @var string The column name */ |
| 11 |
protected string $column; |
| 12 |
|
| 13 |
/** @var Model The target model */ |
| 14 |
protected Model $model; |
| 15 |
|
| 16 |
/** |
| 17 |
* Create a new InvalidColumnException |
| 18 |
* |
| 19 |
* @param string $column The column name |
| 20 |
* @param Model $model The target model |
| 21 |
*/ |
| 22 |
public function __construct(string $column, Model $model) |
| 23 |
{ |
| 24 |
$this->column = $column; |
| 25 |
$this->model = $model; |
| 26 |
|
| 27 |
parent::__construct(sprintf( |
| 28 |
"Can't require column '%s' in model '%s'. Column not found.", |
| 29 |
$column, |
| 30 |
get_class($model) |
| 31 |
)); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Get the column name |
| 36 |
* |
| 37 |
* @return string |
| 38 |
*/ |
| 39 |
public function getColumn(): string |
| 40 |
{ |
| 41 |
return $this->column; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Get the target model |
| 46 |
* |
| 47 |
* @return Model |
| 48 |
*/ |
| 49 |
public function getModel(): Model |
| 50 |
{ |
| 51 |
return $this->model; |
| 52 |
} |
| 53 |
} |