Total Complexity | 2 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | trait DurationTrait |
||
13 | { |
||
14 | /** @var string */ |
||
15 | private static string $duration_regex = '/^ |
||
16 | ([-+]?) |
||
17 | P |
||
18 | (?!$) |
||
19 | (?:(?<years>\d+(?:[\.\,]\d+)?)Y)? |
||
20 | (?:(?<months>\d+(?:[\.\,]\d+)?)M)? |
||
21 | (?:(?<weeks>\d+(?:[\.\,]\d+)?)W)? |
||
22 | (?:(?<days>\d+(?:[\.\,]\d+)?)D)? |
||
23 | (T(?=\d)(?:(?<hours>\d+(?:[\.\,]\d+)?)H)? |
||
24 | (?:(?<minutes>\d+(?:[\.\,]\d+)?)M)? |
||
25 | (?:(?<seconds>\d+(?:[\.\,]\d+)?)S)?)? |
||
26 | $/Dx'; |
||
27 | |||
28 | |||
29 | /** |
||
30 | * @param string $value |
||
31 | * @param string $message |
||
32 | */ |
||
33 | protected static function validDuration(string $value, string $message = ''): void |
||
43 |