Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
42 | 201 | public static function create($duration): DateInterval |
|
43 | { |
||
44 | 201 | if ($duration instanceof Period) { |
|
45 | 3 | return $duration->getDateInterval(); |
|
46 | } |
||
47 | |||
48 | 198 | if ($duration instanceof DateInterval) { |
|
49 | 75 | return $duration; |
|
50 | } |
||
51 | |||
52 | 123 | if (false !== ($second = filter_var($duration, FILTER_VALIDATE_INT))) { |
|
53 | 39 | return new self('PT'.$second.'S'); |
|
54 | } |
||
55 | |||
56 | 84 | return self::createFromDateString($duration); |
|
57 | } |
||
59 |