Passed
Push — main ( c2020d...c060b3 )
by Gabriel
13:36
created

InvalidCastException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
dl 0
loc 9
rs 10
c 1
b 0
f 1
eloc 5
nc 1
nop 3
1
<?php
2
3
namespace ByTIC\DataObjects\Exceptions;
4
5
use RuntimeException;
6
7
/**
8
 * Class InvalidCastException
9
 * @package ByTIC\DataObjects\Exceptions
10
 */
11
class InvalidCastException extends RuntimeException
12
{
13
    /**
14
     * The name of the affected Eloquent model.
15
     *
16
     * @var string
17
     */
18
    public $model;
19
20
    /**
21
     * The name of the column.
22
     *
23
     * @var string
24
     */
25
    public $column;
26
27
    /**
28
     * The name of the cast type.
29
     *
30
     * @var string
31
     */
32
    public $castType;
33
34
    /**
35
     * Create a new exception instance.
36
     *
37
     * @param object $model
38
     * @param string $column
39
     * @param string $castType
40
     * @return static
41
     */
42
    public function __construct($model, $column, $castType)
43
    {
44
        $class = get_class($model);
45
46
        parent::__construct("Call to undefined cast [{$castType}] on column [{$column}] in model [{$class}].");
47
48
        $this->model = $class;
49
        $this->column = $column;
50
        $this->castType = $castType;
51
    }
52
}
53