Passed
Push — master ( 705ab8...a10add )
by Rustam
13:49 queued 11:19
created

NotInstantiableClassException::getSolution()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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
    #[Pure]
16
    public function __construct(string $class, string $message = null, int $code = 0, Exception $previous = null)
17
    {
18
        if ($message === null) {
19
            $message = sprintf(
20
                'Can not instantiate "%s" because it is not a subclass of "%s".',
21
                $class,
22
                RepositoryInterface::class
23
            );
24
        }
25
        parent::__construct($message, $code, $previous);
26
    }
27
28
    public function getSolution(): ?string
29
    {
30
        return 'Make sure that the class is instantiable and implements ' . RepositoryInterface::class;
31
    }
32
33
    public function getName(): string
34
    {
35
        return 'Repository not instantiable';
36
    }
37
}
38