Completed
Push — master ( 7f93f9...c5181d )
by Nikola
01:12
created

Build   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 21
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A empty() 0 10 2
A validate() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Version\Extension;
6
7
use Version\Assert\VersionAssert;
8
9
class Build extends BaseExtension
10
{
11 69
    public static function empty(): Build
12
    {
13 69
        static $noBuild = null;
14
15 69
        if (null === $noBuild) {
16
            $noBuild = new self(...[]);
17
        }
18
19 69
        return $noBuild;
20
    }
21
22 19
    protected function validate(string $identifier): void
23
    {
24 19
        VersionAssert::that($identifier)->regex(
25 19
            '/^[0-9A-Za-z\-]+$/',
26 19
            'Build metadata is not valid; identifiers must include only alphanumerics and hyphen'
27
        );
28 18
    }
29
}
30