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

InvalidExtensionIdentifierException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A forExtensionIdentifier() 0 10 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