NotFoundException::classNotFound()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Habemus\Exception;
5
6
use Psr\Container\NotFoundExceptionInterface;
7
use Throwable;
8
9
class NotFoundException extends ContainerException implements NotFoundExceptionInterface
10
{
11
    public function __construct(string $id, $message = "", $code = 0, Throwable $previous = null)
12
    {
13
        $message = $message ? $message : sprintf("No entry was found in the container for id (%s)", $id);
14
        parent::__construct($message, $code, $previous);
15
    }
16
17
    public static function noEntryWasFound(string $id): self
18
    {
19
        return new self($id);
20
    }
21
22
    public static function classNotFound(string $class): self
23
    {
24
        return new self(
25
            $class,
26
            sprintf("Class not found (%s)", $class)
27
        );
28
    }
29
}
30