Completed
Push — master ( c2ba24...974176 )
by Sergey
28:36 queued 13:30
created

ParentModelNotFoundException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

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