Passed
Push — feature/add-gacela-cli ( 2018fc )
by Chema
05:13 queued 15s
created

CommandArgumentsException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 24
ccs 9
cts 9
cp 1
rs 10
wmc 3

3 Methods

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