Completed
Push — master ( 82c794...6889fd )
by Nikola
05:31
created

forExtensionIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

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.4285
c 0
b 0
f 0
cc 1
eloc 6
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
/**
12
 * @author Nikola Posa <[email protected]>
13
 */
14
class InvalidExtensionIdentifierException extends DomainException implements ExceptionInterface
15
{
16 4
    public static function forExtensionIdentifier(BaseExtension $extension, string $identifier) : self
17
    {
18 4
        $extensionName = (new ReflectionClass($extension))->getShortName();
19
20 4
        return new self(sprintf(
21 4
            "%s identifier: '%s' is not valid; it must comprise only ASCII alphanumerics and hyphen",
22 4
            $extensionName,
23 4
            $identifier
24
        ));
25
    }
26
}
27