summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/orm/src/Exception/InvalidColumnException.php
blob: cd320c6d1795fd17b43804ad00027394f609cbbb (plain)
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
51
52
53
<?php

namespace ipl\Orm\Exception;

use Exception;
use ipl\Orm\Model;

class InvalidColumnException extends Exception
{
    /** @var string The column name */
    protected $column;

    /** @var Model The target model */
    protected $model;

    /**
     * Create a new InvalidColumnException
     *
     * @param string $column The column name
     * @param Model $model The target model
     */
    public function __construct($column, Model $model)
    {
        $this->column = (string) $column;
        $this->model = $model;

        parent::__construct(sprintf(
            "Can't require column '%s' in model '%s'. Column not found.",
            $column,
            get_class($model)
        ));
    }

    /**
     * Get the column name
     *
     * @return string
     */
    public function getColumn()
    {
        return $this->column;
    }

    /**
     * Get the target model
     *
     * @return Model
     */
    public function getModel()
    {
        return $this->model;
    }
}