Conditions | 5 |
Paths | 9 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
41 | public static function fromDateTimeInterval(DateTimeInterval $interval) : DateInterval |
||
42 | { |
||
43 | $string = 'P'; |
||
44 | |||
45 | if ($interval->days) { |
||
46 | $string .= $interval->days . 'D'; |
||
47 | } else { |
||
48 | if ($interval->y) { |
||
49 | $string .= $interval->y . 'Y'; |
||
50 | } |
||
51 | if ($interval->m) { |
||
52 | $string .= $interval->m . 'M'; |
||
53 | } |
||
54 | if ($interval->d) { |
||
55 | $string .= $interval->d . 'D'; |
||
56 | } |
||
57 | } |
||
58 | |||
59 | return new self($string); |
||
60 | } |
||
62 |