CommandArgumentsException::noAutoloadFound()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Console\Domain\CommandArguments;
6
7
use RuntimeException;
8
9
use function sprintf;
10
11
final class CommandArgumentsException extends RuntimeException
12
{
13
    public static function noAutoloadFound(): self
14
    {
15
        return new self('No autoload found in your composer.json');
16
    }
17
18
    public static function noAutoloadPsr4Found(): self
19
    {
20
        return new self('No autoload psr-4 match found in your composer.json');
21
    }
22
23
    /**
24
     * @param list<string> $knownPsr4
25
     */
26
    public static function noAutoloadPsr4MatchFound(string $desiredNamespace, array $knownPsr4 = []): self
27
    {
28
        $parsedKnownPsr4 = array_map(
29
            static fn (string $p): string => str_replace('\\', '', $p),
30
            $knownPsr4,
31
        );
32
33
        return new self(
34
            sprintf(
35
                'No autoload psr-4 match found for %s. Known PSR-4: %s',
36
                $desiredNamespace,
37
                implode(', ', $parsedKnownPsr4),
38
            ),
39
        );
40
    }
41
}
42