mapNotFoundForClassName()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 20
ccs 12
cts 12
cp 1
rs 9.9
cc 3
nc 2
nop 2
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Container\Exception;
6
7
use Psr\Container\NotFoundExceptionInterface;
8
use RuntimeException;
9
10
use function count;
11
12
final class DependencyNotFoundException extends RuntimeException implements NotFoundExceptionInterface
13
{
14
    /**
15
     * @param list<string> $suggestions
16
     */
17 3
    public static function mapNotFoundForClassName(string $className, array $suggestions = []): self
18
    {
19 3
        $message = <<<TXT
20 3
No concrete class was found that implements:
21 3
"{$className}"
22
Did you forget to bind this interface to a concrete class?
23
24 3
TXT;
25
26 3
        if (count($suggestions) > 0) {
27 1
            $message .= "\nDid you mean one of these?\n";
28 1
            foreach ($suggestions as $suggestion) {
29 1
                $message .= "  - {$suggestion}\n";
30
            }
31 1
            $message .= "\n";
32
        }
33
34 3
        $message .= 'You might find some help here: https://gacela-project.com/docs/bootstrap/#bindings';
35
36 3
        return new self($message);
37
    }
38
}
39