Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
20 | 6 | public static function buildFromString(string $string): self |
|
21 | { |
||
22 | // Keep tag names (eg. "v1.2.3") for versioning |
||
23 | 6 | if (preg_match('/^v?\d+\.\d+\.\d+$/', $string)) { |
|
24 | 3 | return new self($string); |
|
25 | } |
||
26 | |||
27 | // Transform version branch (eg. "2.0") to composer style (eg. "2.0.x-dev") |
||
28 | 4 | if (preg_match('/^\d+\.\d+$/', $string)) { |
|
29 | 2 | return new self(sprintf('%s.x-dev', $string)); |
|
30 | } |
||
31 | |||
32 | // Transform feature branch (eg. "master") to composer style (eg. "dev-master") |
||
33 | 2 | return new self(sprintf('dev-%s', $string)); |
|
34 | } |
||
41 |