Passed
Push — master ( 5e9dce...cb103f )
by Aleksei
02:54
created

NotInstantiableClassException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
nc 2
nop 4
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Exception;
6
7
use Cycle\ORM\RepositoryInterface;
8
use Exception;
9
use JetBrains\PhpStorm\Pure;
10
use Psr\Container\ContainerExceptionInterface;
11
use Yiisoft\FriendlyException\FriendlyExceptionInterface;
12
13
final class NotInstantiableClassException extends Exception implements ContainerExceptionInterface, FriendlyExceptionInterface
14
{
15 3
    #[Pure]
16
    public function __construct(string $class, string $message = null, int $code = 0, Exception $previous = null)
17
    {
18 3
        if ($message === null) {
19 3
            $message = sprintf(
20 3
                'Can not instantiate "%s" because it is not a subclass of "%s".',
21 3
                $class,
22 3
                RepositoryInterface::class
23 3
            );
24
        }
25 3
        parent::__construct($message, $code, $previous);
26
    }
27
28 1
    public function getSolution(): ?string
29
    {
30 1
        return 'Make sure that the class is instantiable and implements ' . RepositoryInterface::class;
31
    }
32
33 1
    public function getName(): string
34
    {
35 1
        return 'Repository not instantiable';
36
    }
37
}
38