@@ -18,8 +18,9 @@ discard block |
||
| 18 | 18 | $this->refDT = new DateTimeImmutable('midnight'); |
| 19 | 19 | $invert = FALSE; |
| 20 | 20 | if ($interval instanceof \DateInterval) { |
| 21 | - if ($interval->invert) |
|
| 22 | - $invert = TRUE; |
|
| 21 | + if ($interval->invert) { |
|
| 22 | + $invert = TRUE; |
|
| 23 | + } |
|
| 23 | 24 | $interval = self::parse($interval); |
| 24 | 25 | } elseif (is_string($interval)) { |
| 25 | 26 | if (strpos($interval, '-') === 0) { |
@@ -27,12 +28,14 @@ discard block |
||
| 27 | 28 | $interval = substr($interval, 1); |
| 28 | 29 | } |
| 29 | 30 | } elseif (is_int($interval)) { |
| 30 | - if ($interval < 0) |
|
| 31 | - $invert = TRUE; |
|
| 31 | + if ($interval < 0) { |
|
| 32 | + $invert = TRUE; |
|
| 33 | + } |
|
| 32 | 34 | $interval = sprintf("PT%uS", abs($interval)); |
| 33 | 35 | } elseif (is_float($interval)) { |
| 34 | - if ($interval < 0) |
|
| 35 | - $invert = TRUE; |
|
| 36 | + if ($interval < 0) { |
|
| 37 | + $invert = TRUE; |
|
| 38 | + } |
|
| 36 | 39 | $interval = sprintf("PT%uS", abs(round($interval))); |
| 37 | 40 | } |
| 38 | 41 | try { |
@@ -55,8 +58,9 @@ discard block |
||
| 55 | 58 | $d1->add(new self($interval)); |
| 56 | 59 | $int = ($this->getRefDT())->diff($d1); |
| 57 | 60 | $this->__construct(self::parse($int)); |
| 58 | - if ($d1 < $this->getRefDT()) |
|
| 59 | - $this->invert = 1; |
|
| 61 | + if ($d1 < $this->getRefDT()) { |
|
| 62 | + $this->invert = 1; |
|
| 63 | + } |
|
| 60 | 64 | return $this; |
| 61 | 65 | } |
| 62 | 66 | |
@@ -67,8 +71,9 @@ discard block |
||
| 67 | 71 | $d1->sub(new self($interval)); |
| 68 | 72 | $int = ($this->getRefDT())->diff($d1); |
| 69 | 73 | $this->__construct(self::parse($int)); |
| 70 | - if ($d1 < $this->getRefDT()) |
|
| 71 | - $this->invert = 1; |
|
| 74 | + if ($d1 < $this->getRefDT()) { |
|
| 75 | + $this->invert = 1; |
|
| 76 | + } |
|
| 72 | 77 | return $this; |
| 73 | 78 | } |
| 74 | 79 | |
@@ -128,9 +133,11 @@ discard block |
||
| 128 | 133 | private function validateRelativeFormat($interval, \Exception $e = NULL) |
| 129 | 134 | { |
| 130 | 135 | $parse = date_parse($interval); |
| 131 | - if ($parse['error_count']) |
|
| 132 | - throw new DateInterval\InvalidArgumentException(($e) ? $e->getMessage() : NULL, ($e) ? $e->getCode() : NULL, ($e) ? $e : NULL); |
|
| 133 | - if (!isset($parse['relative'])) |
|
| 134 | - throw new DateInterval\InvalidArgumentException(sprintf("First argument '%s' is not in supported relative date format.", $interval), ($e) ? $e->getCode() : NULL, ($e) ? $e : NULL); |
|
| 136 | + if ($parse['error_count']) { |
|
| 137 | + throw new DateInterval\InvalidArgumentException(($e) ? $e->getMessage() : NULL, ($e) ? $e->getCode() : NULL, ($e) ? $e : NULL); |
|
| 138 | + } |
|
| 139 | + if (!isset($parse['relative'])) { |
|
| 140 | + throw new DateInterval\InvalidArgumentException(sprintf("First argument '%s' is not in supported relative date format.", $interval), ($e) ? $e->getCode() : NULL, ($e) ? $e : NULL); |
|
| 141 | + } |
|
| 135 | 142 | } |
| 136 | 143 | } |