@@ -22,7 +22,7 @@ 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 | return $compare; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | bool $useMicroSeconds = false |
| 46 | 46 | ): bool { |
| 47 | 47 | $compare = $this->compare($this->date($value), $this->date($threshold), $useMicroSeconds); |
| 48 | - if (is_bool($compare)) { |
|
| 48 | + if (is_bool($compare)){ |
|
| 49 | 49 | return $compare; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | private function date($value): ?\DateTimeImmutable |
| 60 | 60 | { |
| 61 | - if ($value instanceof \DateTimeImmutable) { |
|
| 61 | + if ($value instanceof \DateTimeImmutable){ |
|
| 62 | 62 | return $value; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ($value instanceof \DateTime) { |
|
| 65 | + if ($value instanceof \DateTime){ |
|
| 66 | 66 | return \DateTimeImmutable::createFromMutable($value); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | private function compare(?\DateTimeImmutable $date, ?\DateTimeImmutable $threshold, bool $useMicroseconds) |
| 79 | 79 | { |
| 80 | - if ($date === null) { |
|
| 80 | + if ($date === null){ |
|
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if ($threshold === null) { |
|
| 84 | + if ($threshold === null){ |
|
| 85 | 85 | return true; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if (!$useMicroseconds) { |
|
| 88 | + if (!$useMicroseconds){ |
|
| 89 | 89 | $date = $this->dropMicroSeconds($date); |
| 90 | 90 | $threshold = $this->dropMicroSeconds($threshold); |
| 91 | 91 | } |
@@ -82,7 +82,7 @@ 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 | return false; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function timezone($value): bool |
| 112 | 112 | { |
| 113 | - if (!is_scalar($value)) { |
|
| 113 | + if (!is_scalar($value)){ |
|
| 114 | 114 | return false; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | private function now(): ?\DateTimeInterface |
| 152 | 152 | { |
| 153 | - try { |
|
| 153 | + try{ |
|
| 154 | 154 | return $this->date($this->now ?: 'now'); |
| 155 | - } catch (\Throwable $e) { |
|
| 155 | + }catch (\Throwable $e){ |
|
| 156 | 156 | //here's the fail; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -165,25 +165,25 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | private function date($value): ?\DateTimeInterface |
| 167 | 167 | { |
| 168 | - if (is_callable($value)) { |
|
| 168 | + if (is_callable($value)){ |
|
| 169 | 169 | $value = $value(); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - if ($value instanceof \DateTimeInterface) { |
|
| 172 | + if ($value instanceof \DateTimeInterface){ |
|
| 173 | 173 | return $value; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if (!$this->isApplicableValue($value)) { |
|
| 176 | + if (!$this->isApplicableValue($value)){ |
|
| 177 | 177 | return null; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - try { |
|
| 181 | - if (!$value) { |
|
| 180 | + try{ |
|
| 181 | + if (!$value){ |
|
| 182 | 182 | $value = '0'; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | return new \DateTimeImmutable(is_numeric($value) ? sprintf('@%d', $value) : trim($value)); |
| 186 | - } catch (\Throwable $e) { |
|
| 186 | + }catch (\Throwable $e){ |
|
| 187 | 187 | //here's the fail; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | private function fromField(string $field): ?\DateTimeInterface |
| 207 | 207 | { |
| 208 | 208 | $before = $this->getValidator()->getValue($field); |
| 209 | - if ($before !== null) { |
|
| 209 | + if ($before !== null){ |
|
| 210 | 210 | return $this->date($before); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | [true, $callableNow, $now, true, true] |
| 45 | 45 | ]; |
| 46 | 46 | |
| 47 | - $callableFutureTime = static function () { |
|
| 47 | + $callableFutureTime = static function (){ |
|
| 48 | 48 | return time() + 1000; |
| 49 | 49 | }; |
| 50 | 50 | yield from [ |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | [false, $callableFutureTime, $now, true, true], |
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | - $callablePastTime = static function () { |
|
| 55 | + $callablePastTime = static function (){ |
|
| 56 | 56 | return time() - 1000; |
| 57 | 57 | }; |
| 58 | 58 | yield from [ |
@@ -231,24 +231,24 @@ discard block |
||
| 231 | 231 | public function validProvider(): array |
| 232 | 232 | { |
| 233 | 233 | return [ |
| 234 | - [true, time() - 1000,], |
|
| 235 | - [true, time(),], |
|
| 236 | - [true, date('u'),], |
|
| 237 | - [true, time() + 1000,], |
|
| 238 | - [true, '',], |
|
| 239 | - [true, 'tomorrow +2hours',], |
|
| 240 | - [true, 'yesterday -2hours',], |
|
| 241 | - [true, 'now',], |
|
| 242 | - [true, 'now + 1000 seconds',], |
|
| 243 | - [true, 'now - 1000 seconds',], |
|
| 244 | - [true, 0,], |
|
| 245 | - [true, 1.1,], |
|
| 246 | - [false, [],], |
|
| 247 | - [false, false,], |
|
| 248 | - [false, true,], |
|
| 249 | - [false, null,], |
|
| 250 | - [false, [],], |
|
| 251 | - [false, new \stdClass(),], |
|
| 234 | + [true, time() - 1000, ], |
|
| 235 | + [true, time(), ], |
|
| 236 | + [true, date('u'), ], |
|
| 237 | + [true, time() + 1000, ], |
|
| 238 | + [true, '', ], |
|
| 239 | + [true, 'tomorrow +2hours', ], |
|
| 240 | + [true, 'yesterday -2hours', ], |
|
| 241 | + [true, 'now', ], |
|
| 242 | + [true, 'now + 1000 seconds', ], |
|
| 243 | + [true, 'now - 1000 seconds', ], |
|
| 244 | + [true, 0, ], |
|
| 245 | + [true, 1.1, ], |
|
| 246 | + [false, [], ], |
|
| 247 | + [false, false, ], |
|
| 248 | + [false, true, ], |
|
| 249 | + [false, null, ], |
|
| 250 | + [false, [], ], |
|
| 251 | + [false, new \stdClass(), ], |
|
| 252 | 252 | ]; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | { |
| 257 | 257 | $checker = new DatetimeChecker(); |
| 258 | 258 | |
| 259 | - foreach (\DateTimeZone::listIdentifiers() as $identifier) { |
|
| 259 | + foreach (\DateTimeZone::listIdentifiers() as $identifier){ |
|
| 260 | 260 | $this->assertTrue($checker->timezone($identifier)); |
| 261 | 261 | $this->assertFalse($checker->timezone(str_rot13($identifier))); |
| 262 | 262 | } |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | |
| 398 | 398 | private function now(): \Closure |
| 399 | 399 | { |
| 400 | - return static function () { |
|
| 400 | + return static function (){ |
|
| 401 | 401 | return \time(); |
| 402 | 402 | }; |
| 403 | 403 | } |