Completed
Push — master ( 79e89c...34165e )
by Nikola
01:13
created

forExtensionIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Version\Exception;
6
7
use DomainException;
8
use ReflectionClass;
9
use Version\Extension\BaseExtension;
10
11
class InvalidExtensionIdentifier extends DomainException implements VersionException
12
{
13 4
    public static function forExtensionIdentifier(BaseExtension $extension, string $identifier): self
14
    {
15 4
        $extensionName = (new ReflectionClass($extension))->getShortName();
16
17 4
        return new self(sprintf(
18 4
            "%s identifier: '%s' is not valid; it must comprise only ASCII alphanumerics and hyphen",
19 4
            $extensionName,
20 4
            $identifier
21
        ));
22
    }
23
}
24