Passed
Pull Request — master (#148)
by Rustam
12:16
created

NotFoundException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 10
cc 2
nc 2
nop 4
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Exception;
6
7
use Exception;
8
use JetBrains\PhpStorm\Pure;
9
use Psr\Container\NotFoundExceptionInterface;
10
use Yiisoft\FriendlyException\FriendlyExceptionInterface;
11
12
final class NotFoundException extends Exception implements NotFoundExceptionInterface, FriendlyExceptionInterface
13
{
14
    #[Pure]
15
    public function __construct(string $class, string $message = null, int $code = 0, Exception $previous = null)
16
    {
17
        if ($message === null) {
18
            $message = sprintf('No definition or class found or resolvable for "%s".', $class);
19
        }
20
        parent::__construct($message, $code, $previous);
21
    }
22
23
    public function getSolution(): ?string
24
    {
25
        return 'Check if the class exists or if the class is properly defined.';
26
    }
27
28
    public function getName(): string
29
    {
30
        return 'Repository not found';
31
    }
32
}
33