Passed
Pull Request — master (#356)
by Valentin
04:42
created
src/Validation/src/Checker/DatetimeChecker/ThresholdChecker.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Validation/src/Checker/DatetimeChecker.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,18 +150,18 @@  discard block
 block discarded – undo
150 150
      */
151 151
     private function now(): ?\DateTimeInterface
152 152
     {
153
-        try {
154
-            if (is_callable($this->now)) {
153
+        try{
154
+            if (is_callable($this->now)){
155 155
                 $now = $this->now;
156 156
                 return $now();
157 157
             }
158 158
 
159
-            if ($this->now !== null) {
159
+            if ($this->now !== null){
160 160
                 return $this->date($this->now);
161 161
             }
162 162
 
163 163
             return new \DateTimeImmutable('now');
164
-        } catch (\Throwable $e) {
164
+        }catch (\Throwable $e){
165 165
             //here's the fail;
166 166
         }
167 167
 
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
      */
175 175
     private function date($value): ?\DateTimeInterface
176 176
     {
177
-        if ($value instanceof \DateTimeInterface) {
177
+        if ($value instanceof \DateTimeInterface){
178 178
             return $value;
179 179
         }
180 180
 
181
-        if (!$this->isApplicableValue($value)) {
181
+        if (!$this->isApplicableValue($value)){
182 182
             return null;
183 183
         }
184 184
 
185
-        try {
186
-            if (!$value) {
185
+        try{
186
+            if (!$value){
187 187
                 $value = '0';
188 188
             }
189 189
 
190 190
             return new \DateTimeImmutable(is_numeric($value) ? sprintf('@%d', $value) : trim($value));
191
-        } catch (\Throwable $e) {
191
+        }catch (\Throwable $e){
192 192
             //here's the fail;
193 193
         }
194 194
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     private function fromField(string $field): ?\DateTimeInterface
212 212
     {
213 213
         $before = $this->getValidator()->getValue($field);
214
-        if ($before !== null) {
214
+        if ($before !== null){
215 215
             return $this->date($before);
216 216
         }
217 217
 
Please login to merge, or discard this patch.
Braces   +26 added lines, -12 removed lines patch added patch discarded remove patch
@@ -82,7 +82,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -150,18 +152,23 @@  discard block
 block discarded – undo
150 152
      */
151 153
     private function now(): ?\DateTimeInterface
152 154
     {
153
-        try {
154
-            if (is_callable($this->now)) {
155
+        try
156
+        {
157
+            if (is_callable($this->now))
158
+            {
155 159
                 $now = $this->now;
156 160
                 return $now();
157 161
             }
158 162
 
159
-            if ($this->now !== null) {
163
+            if ($this->now !== null)
164
+            {
160 165
                 return $this->date($this->now);
161 166
             }
162 167
 
163 168
             return new \DateTimeImmutable('now');
164
-        } catch (\Throwable $e) {
169
+        }
170
+        catch (\Throwable $e)
171
+        {
165 172
             //here's the fail;
166 173
         }
167 174
 
@@ -174,21 +181,27 @@  discard block
 block discarded – undo
174 181
      */
175 182
     private function date($value): ?\DateTimeInterface
176 183
     {
177
-        if ($value instanceof \DateTimeInterface) {
184
+        if ($value instanceof \DateTimeInterface)
185
+        {
178 186
             return $value;
179 187
         }
180 188
 
181
-        if (!$this->isApplicableValue($value)) {
189
+        if (!$this->isApplicableValue($value))
190
+        {
182 191
             return null;
183 192
         }
184 193
 
185
-        try {
186
-            if (!$value) {
194
+        try
195
+        {
196
+            if (!$value)
197
+            {
187 198
                 $value = '0';
188 199
             }
189 200
 
190 201
             return new \DateTimeImmutable(is_numeric($value) ? sprintf('@%d', $value) : trim($value));
191
-        } catch (\Throwable $e) {
202
+        }
203
+        catch (\Throwable $e)
204
+        {
192 205
             //here's the fail;
193 206
         }
194 207
 
@@ -211,7 +224,8 @@  discard block
 block discarded – undo
211 224
     private function fromField(string $field): ?\DateTimeInterface
212 225
     {
213 226
         $before = $this->getValidator()->getValue($field);
214
-        if ($before !== null) {
227
+        if ($before !== null)
228
+        {
215 229
             return $this->date($before);
216 230
         }
217 231
 
Please login to merge, or discard this patch.