Passed
Push — master ( 8e9a4b...0b4ca3 )
by Sebastian
03:12
created

ClassNotImplementsException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 1
nc 1
nop 4
1
<?php
2
/**
3
 * @package Application Utils
4
 * @subpackage ClassFinder
5
 * @see \AppUtils\ClassHelper\ClassNotImplementsException
6
 */
7
8
declare(strict_types=1);
9
10
namespace AppUtils\ClassHelper;
11
12
use function AppUtils\parseVariable;
13
use Throwable;
14
15
/**
16
 * @package Application Utils
17
 * @subpackage ClassFinder
18
 * @author Sebastian Mordziol <[email protected]>
19
 */
20
class ClassNotImplementsException extends BaseClassHelperException
21
{
22
    /**
23
     * @param string $expectedClass
24
     * @param mixed $given
25
     * @param int|null $code
26
     * @param Throwable|null $previous
27
     */
28
    public function __construct(string $expectedClass, $given, ?int $code = null, ?Throwable $previous = null)
29
    {
30
        parent::__construct(
31
            'Subject does not extend the expected class.',
32
            sprintf(
33
                'Expected an instance of [%s], given: [%s].',
34
                $expectedClass,
35
                parseVariable($given)->enableType()->toString()
36
            ),
37
            $code,
38
            $previous
39
        );
40
    }
41
}
42