CommandArgumentsException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A noAutoloadPsr4Found() 0 3 1
A noAutoloadPsr4MatchFound() 0 12 1
A noAutoloadFound() 0 3 1
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