@@ -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 | } |
@@ -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,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 | |
@@ -151,21 +151,21 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | private function date($value): ?\DateTimeInterface |
| 153 | 153 | { |
| 154 | - if ($value instanceof \DateTimeInterface) { |
|
| 154 | + if ($value instanceof \DateTimeInterface){ |
|
| 155 | 155 | return $value; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if (!$this->isApplicableValue($value)) { |
|
| 158 | + if (!$this->isApplicableValue($value)){ |
|
| 159 | 159 | return null; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - try { |
|
| 163 | - if (!$value) { |
|
| 162 | + try{ |
|
| 163 | + if (!$value){ |
|
| 164 | 164 | $value = '0'; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | return new \DateTimeImmutable(is_numeric($value) ? sprintf('@%d', $value) : trim($value)); |
| 168 | - } catch (\Throwable $e) { |
|
| 168 | + }catch (\Throwable $e){ |
|
| 169 | 169 | //here's the fail; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -186,14 +186,14 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | private function now(): ?\DateTimeInterface |
| 188 | 188 | { |
| 189 | - try { |
|
| 190 | - if (is_callable($this->now)) { |
|
| 189 | + try{ |
|
| 190 | + if (is_callable($this->now)){ |
|
| 191 | 191 | $now = $this->now; |
| 192 | 192 | return $now(); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | return new \DateTimeImmutable('now'); |
| 196 | - } catch (\Throwable $e) { |
|
| 196 | + }catch (\Throwable $e){ |
|
| 197 | 197 | //here's the fail; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | private function fromField(string $field): ?\DateTimeInterface |
| 208 | 208 | { |
| 209 | 209 | $before = $this->getValidator()->getValue($field); |
| 210 | - if ($before !== null) { |
|
| 210 | + if ($before !== null){ |
|
| 211 | 211 | return $this->date($before); |
| 212 | 212 | } |
| 213 | 213 | |
@@ -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 | |