Completed
Push — master ( 816340...ab4a72 )
by Sergey
05:20
created

ModelNotFoundException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
ccs 0
cts 11
cp 0
rs 9.4285
cc 2
eloc 8
nc 2
nop 2
crap 6
1
<?php
2
3
namespace Isswp101\Persimmon\Exceptions;
4
5
use Illuminate\Database\Eloquent\ModelNotFoundException as Exception;
6
use ReflectionClass;
7
8
class ModelNotFoundException extends Exception
9
{
10
    public function __construct($class, $id = null)
11
    {
12
        $reflection = new ReflectionClass($class);
13
14
        $model = $reflection->getShortName();
15
16
        if ($id) {
17
            $message = sprintf('Model `%s` not found by id `%s`', $model, $id);
18
        } else {
19
            $message = sprintf('Model `%s` not found', $model);
20
        }
21
22
        parent::__construct($message);
23
    }
24
}
25