@@ -22,7 +22,8 @@ discard block |
||
| 22 | 22 | bool $useMicroSeconds = false |
| 23 | 23 | ): bool { |
| 24 | 24 | $compare = $this->compare($this->date($value), $this->date($threshold), $useMicroSeconds); |
| 25 | - if (is_bool($compare)) { |
|
| 25 | + if (is_bool($compare)) |
|
| 26 | + { |
|
| 26 | 27 | return $compare; |
| 27 | 28 | } |
| 28 | 29 | |
@@ -45,7 +46,8 @@ discard block |
||
| 45 | 46 | bool $useMicroSeconds = false |
| 46 | 47 | ): bool { |
| 47 | 48 | $compare = $this->compare($this->date($value), $this->date($threshold), $useMicroSeconds); |
| 48 | - if (is_bool($compare)) { |
|
| 49 | + if (is_bool($compare)) |
|
| 50 | + { |
|
| 49 | 51 | return $compare; |
| 50 | 52 | } |
| 51 | 53 | |
@@ -58,11 +60,13 @@ discard block |
||
| 58 | 60 | */ |
| 59 | 61 | private function date($value): ?\DateTimeImmutable |
| 60 | 62 | { |
| 61 | - if ($value instanceof \DateTimeImmutable) { |
|
| 63 | + if ($value instanceof \DateTimeImmutable) |
|
| 64 | + { |
|
| 62 | 65 | return $value; |
| 63 | 66 | } |
| 64 | 67 | |
| 65 | - if ($value instanceof \DateTime) { |
|
| 68 | + if ($value instanceof \DateTime) |
|
| 69 | + { |
|
| 66 | 70 | return \DateTimeImmutable::createFromMutable($value); |
| 67 | 71 | } |
| 68 | 72 | |
@@ -77,15 +81,18 @@ discard block |
||
| 77 | 81 | */ |
| 78 | 82 | private function compare(?\DateTimeImmutable $date, ?\DateTimeImmutable $threshold, bool $useMicroseconds) |
| 79 | 83 | { |
| 80 | - if ($date === null) { |
|
| 84 | + if ($date === null) |
|
| 85 | + { |
|
| 81 | 86 | return false; |
| 82 | 87 | } |
| 83 | 88 | |
| 84 | - if ($threshold === null) { |
|
| 89 | + if ($threshold === null) |
|
| 90 | + { |
|
| 85 | 91 | return true; |
| 86 | 92 | } |
| 87 | 93 | |
| 88 | - if (!$useMicroseconds) { |
|
| 94 | + if (!$useMicroseconds) |
|
| 95 | + { |
|
| 89 | 96 | $date = $this->dropMicroSeconds($date); |
| 90 | 97 | $threshold = $this->dropMicroSeconds($threshold); |
| 91 | 98 | } |
@@ -82,7 +82,8 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function format($value, string $format): bool |
| 84 | 84 | { |
| 85 | - if (!$this->isApplicableValue($value)) { |
|
| 85 | + if (!$this->isApplicableValue($value)) |
|
| 86 | + { |
|
| 86 | 87 | return false; |
| 87 | 88 | } |
| 88 | 89 | |
@@ -110,7 +111,8 @@ discard block |
||
| 110 | 111 | */ |
| 111 | 112 | public function timezone($value): bool |
| 112 | 113 | { |
| 113 | - if (!is_scalar($value)) { |
|
| 114 | + if (!is_scalar($value)) |
|
| 115 | + { |
|
| 114 | 116 | return false; |
| 115 | 117 | } |
| 116 | 118 | |
@@ -151,21 +153,27 @@ discard block |
||
| 151 | 153 | */ |
| 152 | 154 | private function date($value): ?\DateTimeInterface |
| 153 | 155 | { |
| 154 | - if ($value instanceof \DateTimeInterface) { |
|
| 156 | + if ($value instanceof \DateTimeInterface) |
|
| 157 | + { |
|
| 155 | 158 | return $value; |
| 156 | 159 | } |
| 157 | 160 | |
| 158 | - if (!$this->isApplicableValue($value)) { |
|
| 161 | + if (!$this->isApplicableValue($value)) |
|
| 162 | + { |
|
| 159 | 163 | return null; |
| 160 | 164 | } |
| 161 | 165 | |
| 162 | - try { |
|
| 163 | - if (!$value) { |
|
| 166 | + try |
|
| 167 | + { |
|
| 168 | + if (!$value) |
|
| 169 | + { |
|
| 164 | 170 | $value = '0'; |
| 165 | 171 | } |
| 166 | 172 | |
| 167 | 173 | return new \DateTimeImmutable(is_numeric($value) ? sprintf('@%d', $value) : trim($value)); |
| 168 | - } catch (\Throwable $e) { |
|
| 174 | + } |
|
| 175 | + catch (\Throwable $e) |
|
| 176 | + { |
|
| 169 | 177 | //here's the fail; |
| 170 | 178 | } |
| 171 | 179 | |
@@ -186,14 +194,18 @@ discard block |
||
| 186 | 194 | */ |
| 187 | 195 | private function now(): ?\DateTimeInterface |
| 188 | 196 | { |
| 189 | - try { |
|
| 190 | - if (is_callable($this->now)) { |
|
| 197 | + try |
|
| 198 | + { |
|
| 199 | + if (is_callable($this->now)) |
|
| 200 | + { |
|
| 191 | 201 | $now = $this->now; |
| 192 | 202 | return $now(); |
| 193 | 203 | } |
| 194 | 204 | |
| 195 | 205 | return new \DateTimeImmutable('now'); |
| 196 | - } catch (\Throwable $e) { |
|
| 206 | + } |
|
| 207 | + catch (\Throwable $e) |
|
| 208 | + { |
|
| 197 | 209 | //here's the fail; |
| 198 | 210 | } |
| 199 | 211 | |
@@ -207,7 +219,8 @@ discard block |
||
| 207 | 219 | private function fromField(string $field): ?\DateTimeInterface |
| 208 | 220 | { |
| 209 | 221 | $before = $this->getValidator()->getValue($field); |
| 210 | - if ($before !== null) { |
|
| 222 | + if ($before !== null) |
|
| 223 | + { |
|
| 211 | 224 | return $this->date($before); |
| 212 | 225 | } |
| 213 | 226 | |