Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
ApplicationVersion
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 convert
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRegularExpression
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toSemanticVersion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\CommonValueObjects;
3
4use Apie\Core\Attributes\Description;
5use Apie\Core\ValueObjects\Interfaces\HasRegexValueObjectInterface;
6use Apie\Core\ValueObjects\IsStringWithRegexValueObject;
7
8#[Description('A semantic version without any suffix, for example "1.0.0"')]
9class ApplicationVersion implements HasRegexValueObjectInterface
10{
11    use IsStringWithRegexValueObject;
12
13    protected function convert(string $input): string
14    {
15        return trim($input);
16    }
17
18    public static function getRegularExpression(): string
19    {
20        return '/^[1-9]*[0-9]\.[1-9]*[0-9]\.[1-9]*[0-9]$/';
21    }
22
23    public function toSemanticVersion(): SemanticVersion
24    {
25        return new SemanticVersion($this->internal);
26    }
27}