Passed
Pull Request — master (#656)
by Abdul Malik
07:05
created
src/Console/src/Config/ConsoleConfig.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function getCommands(): array
50 50
     {
51
-        if (!array_key_exists('commands', $this->config)) {
51
+        if (!array_key_exists('commands', $this->config)){
52 52
             //Legacy config support
53 53
             return [];
54 54
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     public function configureSequence(): Generator
67 67
     {
68 68
         $sequence = $this->config['configure'] ?? $this->config['configureSequence'] ?? [];
69
-        foreach ($sequence as $item) {
69
+        foreach ($sequence as $item){
70 70
             yield $this->parseSequence($item);
71 71
         }
72 72
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     public function updateSequence(): Generator
82 82
     {
83 83
         $sequence = $this->config['update'] ?? $this->config['updateSequence'] ?? [];
84
-        foreach ($sequence as $item) {
84
+        foreach ($sequence as $item){
85 85
             yield $this->parseSequence($item);
86 86
         }
87 87
     }
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
      */
94 94
     protected function parseSequence($item): SequenceInterface
95 95
     {
96
-        if ($item instanceof SequenceInterface) {
96
+        if ($item instanceof SequenceInterface){
97 97
             return $item;
98 98
         }
99 99
 
100
-        if (is_string($item)) {
100
+        if (is_string($item)){
101 101
             return new CallableSequence($item);
102 102
         }
103 103
 
104
-        if (is_array($item) && isset($item['command'])) {
104
+        if (is_array($item) && isset($item['command'])){
105 105
             return new CommandSequence(
106 106
                 $item['command'],
107 107
                 $item['options'] ?? [],
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             );
111 111
         }
112 112
 
113
-        if (is_array($item) && isset($item['invoke'])) {
113
+        if (is_array($item) && isset($item['invoke'])){
114 114
             return new CallableSequence(
115 115
                 $item['invoke'],
116 116
                 $item['parameters'] ?? [],
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function getCommands(): array
50 50
     {
51
-        if (!array_key_exists('commands', $this->config)) {
51
+        if (!array_key_exists('commands', $this->config))
52
+        {
52 53
             //Legacy config support
53 54
             return [];
54 55
         }
@@ -66,7 +67,8 @@  discard block
 block discarded – undo
66 67
     public function configureSequence(): Generator
67 68
     {
68 69
         $sequence = $this->config['configure'] ?? $this->config['configureSequence'] ?? [];
69
-        foreach ($sequence as $item) {
70
+        foreach ($sequence as $item)
71
+        {
70 72
             yield $this->parseSequence($item);
71 73
         }
72 74
     }
@@ -81,7 +83,8 @@  discard block
 block discarded – undo
81 83
     public function updateSequence(): Generator
82 84
     {
83 85
         $sequence = $this->config['update'] ?? $this->config['updateSequence'] ?? [];
84
-        foreach ($sequence as $item) {
86
+        foreach ($sequence as $item)
87
+        {
85 88
             yield $this->parseSequence($item);
86 89
         }
87 90
     }
@@ -93,15 +96,18 @@  discard block
 block discarded – undo
93 96
      */
94 97
     protected function parseSequence($item): SequenceInterface
95 98
     {
96
-        if ($item instanceof SequenceInterface) {
99
+        if ($item instanceof SequenceInterface)
100
+        {
97 101
             return $item;
98 102
         }
99 103
 
100
-        if (is_string($item)) {
104
+        if (is_string($item))
105
+        {
101 106
             return new CallableSequence($item);
102 107
         }
103 108
 
104
-        if (is_array($item) && isset($item['command'])) {
109
+        if (is_array($item) && isset($item['command']))
110
+        {
105 111
             return new CommandSequence(
106 112
                 $item['command'],
107 113
                 $item['options'] ?? [],
@@ -110,7 +116,8 @@  discard block
 block discarded – undo
110 116
             );
111 117
         }
112 118
 
113
-        if (is_array($item) && isset($item['invoke'])) {
119
+        if (is_array($item) && isset($item['invoke']))
120
+        {
114 121
             return new CallableSequence(
115 122
                 $item['invoke'],
116 123
                 $item['parameters'] ?? [],
Please login to merge, or discard this patch.
src/Console/src/Sequence/CallableSequence.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         array $parameters = [],
36 36
         string $header = '',
37 37
         string $footer = ''
38
-    ) {
38
+    ){
39 39
         $this->function = $function;
40 40
 
41 41
         parent::__construct($header, $footer);
@@ -47,18 +47,18 @@  discard block
 block discarded – undo
47 47
     public function execute(ContainerInterface $container, OutputInterface $output): void
48 48
     {
49 49
         $function = $this->function;
50
-        if (is_string($function) && strpos($function, ':') !== false) {
50
+        if (is_string($function) && strpos($function, ':') !== false){
51 51
             $function = explode(':', str_replace('::', ':', $function));
52 52
         }
53 53
 
54
-        if (is_array($function) && isset($function[0]) && !is_object($function[0])) {
54
+        if (is_array($function) && isset($function[0]) && !is_object($function[0])){
55 55
             $function[0] = $container->get($function[0]);
56 56
         }
57 57
 
58 58
         /** @var ResolverInterface $resolver */
59 59
         $resolver = $container->get(ResolverInterface::class);
60 60
 
61
-        if (is_array($function)) {
61
+        if (is_array($function)){
62 62
             $reflection = new ReflectionMethod($function[0], $function[1]);
63 63
             $reflection->invokeArgs($function[0], $resolver->resolveArguments($reflection, [
64 64
                 'output' => $output,
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,18 +47,21 @@
 block discarded – undo
47 47
     public function execute(ContainerInterface $container, OutputInterface $output): void
48 48
     {
49 49
         $function = $this->function;
50
-        if (is_string($function) && strpos($function, ':') !== false) {
50
+        if (is_string($function) && strpos($function, ':') !== false)
51
+        {
51 52
             $function = explode(':', str_replace('::', ':', $function));
52 53
         }
53 54
 
54
-        if (is_array($function) && isset($function[0]) && !is_object($function[0])) {
55
+        if (is_array($function) && isset($function[0]) && !is_object($function[0]))
56
+        {
55 57
             $function[0] = $container->get($function[0]);
56 58
         }
57 59
 
58 60
         /** @var ResolverInterface $resolver */
59 61
         $resolver = $container->get(ResolverInterface::class);
60 62
 
61
-        if (is_array($function)) {
63
+        if (is_array($function))
64
+        {
62 65
             $reflection = new ReflectionMethod($function[0], $function[1]);
63 66
             $reflection->invokeArgs($function[0], $resolver->resolveArguments($reflection, [
64 67
                 'output' => $output,
Please login to merge, or discard this patch.
src/Files/src/Files.php 2 patches
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function __destruct()
50 50
     {
51
-        foreach ($this->destructFiles as $filename) {
51
+        foreach ($this->destructFiles as $filename){
52 52
             $this->delete($filename);
53 53
         }
54 54
     }
@@ -63,30 +63,30 @@  discard block
 block discarded – undo
63 63
         int $mode = null,
64 64
         bool $recursivePermissions = true
65 65
     ): bool {
66
-        if (empty($mode)) {
66
+        if (empty($mode)){
67 67
             $mode = self::DEFAULT_FILE_MODE;
68 68
         }
69 69
 
70 70
         //Directories always executable
71 71
         $mode = $mode | 0111;
72
-        if (is_dir($directory)) {
72
+        if (is_dir($directory)){
73 73
             //Exists :(
74 74
             return $this->setPermissions($directory, $mode);
75 75
         }
76 76
 
77
-        if (!$recursivePermissions) {
77
+        if (!$recursivePermissions){
78 78
             return mkdir($directory, $mode, true);
79 79
         }
80 80
 
81 81
         $directoryChain = [basename($directory)];
82 82
 
83 83
         $baseDirectory = $directory;
84
-        while (!is_dir($baseDirectory = dirname($baseDirectory))) {
84
+        while (!is_dir($baseDirectory = dirname($baseDirectory))){
85 85
             $directoryChain[] = basename($baseDirectory);
86 86
         }
87 87
 
88
-        foreach (array_reverse($directoryChain) as $directory) {
89
-            if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}")) {
88
+        foreach (array_reverse($directoryChain) as $directory){
89
+            if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}")){
90 90
                 return false;
91 91
             }
92 92
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public function read(string $filename): string
103 103
     {
104
-        if (!$this->exists($filename)) {
104
+        if (!$this->exists($filename)){
105 105
             throw new FileNotFoundException($filename);
106 106
         }
107 107
 
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
     ): bool {
123 123
         $mode ??= self::DEFAULT_FILE_MODE;
124 124
 
125
-        try {
126
-            if ($ensureDirectory) {
125
+        try{
126
+            if ($ensureDirectory){
127 127
                 $this->ensureDirectory(dirname($filename), $mode);
128 128
             }
129 129
 
130
-            if ($this->exists($filename)) {
130
+            if ($this->exists($filename)){
131 131
                 //Forcing mode for existed file
132 132
                 $this->setPermissions($filename, $mode);
133 133
             }
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
                 $append ? FILE_APPEND | LOCK_EX : LOCK_EX
139 139
             );
140 140
 
141
-            if ($result !== false) {
141
+            if ($result !== false){
142 142
                 //Forcing mode after file creation
143 143
                 $this->setPermissions($filename, $mode);
144 144
             }
145
-        } catch (Exception $e) {
145
+        }catch (Exception $e){
146 146
             throw new WriteErrorException($e->getMessage(), $e->getCode(), $e);
147 147
         }
148 148
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public function delete(string $filename)
168 168
     {
169
-        if ($this->exists($filename)) {
169
+        if ($this->exists($filename)){
170 170
             $result = unlink($filename);
171 171
 
172 172
             //Wiping out changes in local file cache
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function deleteDirectory(string $directory, bool $contentOnly = false): void
190 190
     {
191
-        if (!$this->isDirectory($directory)) {
191
+        if (!$this->isDirectory($directory)){
192 192
             throw new FilesException("Undefined or invalid directory {$directory}");
193 193
         }
194 194
 
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
             RecursiveIteratorIterator::CHILD_FIRST
198 198
         );
199 199
 
200
-        foreach ($files as $file) {
201
-            if ($file->isDir()) {
200
+        foreach ($files as $file){
201
+            if ($file->isDir()){
202 202
                 rmdir($file->getRealPath());
203
-            } else {
203
+            }else{
204 204
                 $this->delete($file->getRealPath());
205 205
             }
206 206
         }
207 207
 
208
-        if (!$contentOnly) {
208
+        if (!$contentOnly){
209 209
             rmdir($directory);
210 210
         }
211 211
     }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
      */
216 216
     public function move(string $filename, string $destination): bool
217 217
     {
218
-        if (!$this->exists($filename)) {
218
+        if (!$this->exists($filename)){
219 219
             throw new FileNotFoundException($filename);
220 220
         }
221 221
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     public function copy(string $filename, string $destination): bool
229 229
     {
230
-        if (!$this->exists($filename)) {
230
+        if (!$this->exists($filename)){
231 231
             throw new FileNotFoundException($filename);
232 232
         }
233 233
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      */
240 240
     public function touch(string $filename, int $mode = null): bool
241 241
     {
242
-        if (!touch($filename)) {
242
+        if (!touch($filename)){
243 243
             return false;
244 244
         }
245 245
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public function size(string $filename): int
261 261
     {
262
-        if (!$this->exists($filename)) {
262
+        if (!$this->exists($filename)){
263 263
             throw new FileNotFoundException($filename);
264 264
         }
265 265
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
      */
280 280
     public function md5(string $filename): string
281 281
     {
282
-        if (!$this->exists($filename)) {
282
+        if (!$this->exists($filename)){
283 283
             throw new FileNotFoundException($filename);
284 284
         }
285 285
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
      */
292 292
     public function time(string $filename): int
293 293
     {
294
-        if (!$this->exists($filename)) {
294
+        if (!$this->exists($filename)){
295 295
             throw new FileNotFoundException($filename);
296 296
         }
297 297
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
      */
320 320
     public function getPermissions(string $filename): int
321 321
     {
322
-        if (!$this->exists($filename)) {
322
+        if (!$this->exists($filename)){
323 323
             throw new FileNotFoundException($filename);
324 324
         }
325 325
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      */
332 332
     public function setPermissions(string $filename, int $mode)
333 333
     {
334
-        if (is_dir($filename)) {
334
+        if (is_dir($filename)){
335 335
             //Directories must always be executable (i.e. 664 for dir => 775)
336 336
             $mode |= 0111;
337 337
         }
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
     public function getFiles(string $location, string $pattern = null): array
346 346
     {
347 347
         $result = [];
348
-        foreach ($this->filesIterator($location, $pattern) as $filename) {
349
-            if ($this->isDirectory($filename->getPathname())) {
350
-                $result = array_merge($result, $this->getFiles($filename . DIRECTORY_SEPARATOR));
348
+        foreach ($this->filesIterator($location, $pattern) as $filename){
349
+            if ($this->isDirectory($filename->getPathname())){
350
+                $result = array_merge($result, $this->getFiles($filename.DIRECTORY_SEPARATOR));
351 351
 
352 352
                 continue;
353 353
             }
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
      */
364 364
     public function tempFilename(string $extension = '', string $location = null): string
365 365
     {
366
-        if (empty($location)) {
366
+        if (empty($location)){
367 367
             $location = sys_get_temp_dir();
368 368
         }
369 369
 
370 370
         $filename = tempnam($location, 'spiral');
371 371
 
372
-        if (!empty($extension)) {
372
+        if (!empty($extension)){
373 373
             [$old, $filename] = [$filename, "{$filename}.{$extension}"];
374 374
             rename($old, $filename);
375 375
             $this->destructFiles[] = $filename;
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
         $path = str_replace(['//', '\\'], '/', $path);
387 387
 
388 388
         //Potentially open links and ../ type directories?
389
-        return rtrim($path, '/') . ($asDirectory ? '/' : '');
389
+        return rtrim($path, '/').($asDirectory ? '/' : '');
390 390
     }
391 391
 
392 392
     /**
@@ -403,21 +403,21 @@  discard block
 block discarded – undo
403 403
         $path = explode('/', $path);
404 404
         $relative = $path;
405 405
 
406
-        foreach ($from as $depth => $dir) {
406
+        foreach ($from as $depth => $dir){
407 407
             //Find first non-matching dir
408
-            if ($dir === $path[$depth]) {
408
+            if ($dir === $path[$depth]){
409 409
                 //Ignore this directory
410 410
                 array_shift($relative);
411
-            } else {
411
+            }else{
412 412
                 //Get number of remaining dirs to $from
413 413
                 $remaining = count($from) - $depth;
414
-                if ($remaining > 1) {
414
+                if ($remaining > 1){
415 415
                     //Add traversals up to first matching directory
416 416
                     $padLength = (count($relative) + $remaining - 1) * -1;
417 417
                     $relative = array_pad($relative, $padLength, '..');
418 418
                     break;
419 419
                 }
420
-                $relative[0] = './' . $relative[0];
420
+                $relative[0] = './'.$relative[0];
421 421
             }
422 422
         }
423 423
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
     private function filesIterator(string $location, string $pattern = null): GlobIterator
432 432
     {
433 433
         $pattern ??= '*';
434
-        $regexp = rtrim($location, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($pattern, DIRECTORY_SEPARATOR);
434
+        $regexp = rtrim($location, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.ltrim($pattern, DIRECTORY_SEPARATOR);
435 435
 
436 436
         return new GlobIterator($regexp);
437 437
     }
Please login to merge, or discard this patch.
Braces   +73 added lines, -35 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function __destruct()
50 50
     {
51
-        foreach ($this->destructFiles as $filename) {
51
+        foreach ($this->destructFiles as $filename)
52
+        {
52 53
             $this->delete($filename);
53 54
         }
54 55
     }
@@ -63,30 +64,36 @@  discard block
 block discarded – undo
63 64
         int $mode = null,
64 65
         bool $recursivePermissions = true
65 66
     ): bool {
66
-        if (empty($mode)) {
67
+        if (empty($mode))
68
+        {
67 69
             $mode = self::DEFAULT_FILE_MODE;
68 70
         }
69 71
 
70 72
         //Directories always executable
71 73
         $mode = $mode | 0111;
72
-        if (is_dir($directory)) {
74
+        if (is_dir($directory))
75
+        {
73 76
             //Exists :(
74 77
             return $this->setPermissions($directory, $mode);
75 78
         }
76 79
 
77
-        if (!$recursivePermissions) {
80
+        if (!$recursivePermissions)
81
+        {
78 82
             return mkdir($directory, $mode, true);
79 83
         }
80 84
 
81 85
         $directoryChain = [basename($directory)];
82 86
 
83 87
         $baseDirectory = $directory;
84
-        while (!is_dir($baseDirectory = dirname($baseDirectory))) {
88
+        while (!is_dir($baseDirectory = dirname($baseDirectory)))
89
+        {
85 90
             $directoryChain[] = basename($baseDirectory);
86 91
         }
87 92
 
88
-        foreach (array_reverse($directoryChain) as $directory) {
89
-            if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}")) {
93
+        foreach (array_reverse($directoryChain) as $directory)
94
+        {
95
+            if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}"))
96
+            {
90 97
                 return false;
91 98
             }
92 99
 
@@ -101,7 +108,8 @@  discard block
 block discarded – undo
101 108
      */
102 109
     public function read(string $filename): string
103 110
     {
104
-        if (!$this->exists($filename)) {
111
+        if (!$this->exists($filename))
112
+        {
105 113
             throw new FileNotFoundException($filename);
106 114
         }
107 115
 
@@ -122,12 +130,15 @@  discard block
 block discarded – undo
122 130
     ): bool {
123 131
         $mode ??= self::DEFAULT_FILE_MODE;
124 132
 
125
-        try {
126
-            if ($ensureDirectory) {
133
+        try
134
+        {
135
+            if ($ensureDirectory)
136
+            {
127 137
                 $this->ensureDirectory(dirname($filename), $mode);
128 138
             }
129 139
 
130
-            if ($this->exists($filename)) {
140
+            if ($this->exists($filename))
141
+            {
131 142
                 //Forcing mode for existed file
132 143
                 $this->setPermissions($filename, $mode);
133 144
             }
@@ -138,11 +149,14 @@  discard block
 block discarded – undo
138 149
                 $append ? FILE_APPEND | LOCK_EX : LOCK_EX
139 150
             );
140 151
 
141
-            if ($result !== false) {
152
+            if ($result !== false)
153
+            {
142 154
                 //Forcing mode after file creation
143 155
                 $this->setPermissions($filename, $mode);
144 156
             }
145
-        } catch (Exception $e) {
157
+        }
158
+        catch (Exception $e)
159
+        {
146 160
             throw new WriteErrorException($e->getMessage(), $e->getCode(), $e);
147 161
         }
148 162
 
@@ -166,7 +180,8 @@  discard block
 block discarded – undo
166 180
      */
167 181
     public function delete(string $filename)
168 182
     {
169
-        if ($this->exists($filename)) {
183
+        if ($this->exists($filename))
184
+        {
170 185
             $result = unlink($filename);
171 186
 
172 187
             //Wiping out changes in local file cache
@@ -188,7 +203,8 @@  discard block
 block discarded – undo
188 203
      */
189 204
     public function deleteDirectory(string $directory, bool $contentOnly = false): void
190 205
     {
191
-        if (!$this->isDirectory($directory)) {
206
+        if (!$this->isDirectory($directory))
207
+        {
192 208
             throw new FilesException("Undefined or invalid directory {$directory}");
193 209
         }
194 210
 
@@ -197,15 +213,20 @@  discard block
 block discarded – undo
197 213
             RecursiveIteratorIterator::CHILD_FIRST
198 214
         );
199 215
 
200
-        foreach ($files as $file) {
201
-            if ($file->isDir()) {
216
+        foreach ($files as $file)
217
+        {
218
+            if ($file->isDir())
219
+            {
202 220
                 rmdir($file->getRealPath());
203
-            } else {
221
+            }
222
+            else
223
+            {
204 224
                 $this->delete($file->getRealPath());
205 225
             }
206 226
         }
207 227
 
208
-        if (!$contentOnly) {
228
+        if (!$contentOnly)
229
+        {
209 230
             rmdir($directory);
210 231
         }
211 232
     }
@@ -215,7 +236,8 @@  discard block
 block discarded – undo
215 236
      */
216 237
     public function move(string $filename, string $destination): bool
217 238
     {
218
-        if (!$this->exists($filename)) {
239
+        if (!$this->exists($filename))
240
+        {
219 241
             throw new FileNotFoundException($filename);
220 242
         }
221 243
 
@@ -227,7 +249,8 @@  discard block
 block discarded – undo
227 249
      */
228 250
     public function copy(string $filename, string $destination): bool
229 251
     {
230
-        if (!$this->exists($filename)) {
252
+        if (!$this->exists($filename))
253
+        {
231 254
             throw new FileNotFoundException($filename);
232 255
         }
233 256
 
@@ -239,7 +262,8 @@  discard block
 block discarded – undo
239 262
      */
240 263
     public function touch(string $filename, int $mode = null): bool
241 264
     {
242
-        if (!touch($filename)) {
265
+        if (!touch($filename))
266
+        {
243 267
             return false;
244 268
         }
245 269
 
@@ -259,7 +283,8 @@  discard block
 block discarded – undo
259 283
      */
260 284
     public function size(string $filename): int
261 285
     {
262
-        if (!$this->exists($filename)) {
286
+        if (!$this->exists($filename))
287
+        {
263 288
             throw new FileNotFoundException($filename);
264 289
         }
265 290
 
@@ -279,7 +304,8 @@  discard block
 block discarded – undo
279 304
      */
280 305
     public function md5(string $filename): string
281 306
     {
282
-        if (!$this->exists($filename)) {
307
+        if (!$this->exists($filename))
308
+        {
283 309
             throw new FileNotFoundException($filename);
284 310
         }
285 311
 
@@ -291,7 +317,8 @@  discard block
 block discarded – undo
291 317
      */
292 318
     public function time(string $filename): int
293 319
     {
294
-        if (!$this->exists($filename)) {
320
+        if (!$this->exists($filename))
321
+        {
295 322
             throw new FileNotFoundException($filename);
296 323
         }
297 324
 
@@ -319,7 +346,8 @@  discard block
 block discarded – undo
319 346
      */
320 347
     public function getPermissions(string $filename): int
321 348
     {
322
-        if (!$this->exists($filename)) {
349
+        if (!$this->exists($filename))
350
+        {
323 351
             throw new FileNotFoundException($filename);
324 352
         }
325 353
 
@@ -331,7 +359,8 @@  discard block
 block discarded – undo
331 359
      */
332 360
     public function setPermissions(string $filename, int $mode)
333 361
     {
334
-        if (is_dir($filename)) {
362
+        if (is_dir($filename))
363
+        {
335 364
             //Directories must always be executable (i.e. 664 for dir => 775)
336 365
             $mode |= 0111;
337 366
         }
@@ -345,8 +374,10 @@  discard block
 block discarded – undo
345 374
     public function getFiles(string $location, string $pattern = null): array
346 375
     {
347 376
         $result = [];
348
-        foreach ($this->filesIterator($location, $pattern) as $filename) {
349
-            if ($this->isDirectory($filename->getPathname())) {
377
+        foreach ($this->filesIterator($location, $pattern) as $filename)
378
+        {
379
+            if ($this->isDirectory($filename->getPathname()))
380
+            {
350 381
                 $result = array_merge($result, $this->getFiles($filename . DIRECTORY_SEPARATOR));
351 382
 
352 383
                 continue;
@@ -363,13 +394,15 @@  discard block
 block discarded – undo
363 394
      */
364 395
     public function tempFilename(string $extension = '', string $location = null): string
365 396
     {
366
-        if (empty($location)) {
397
+        if (empty($location))
398
+        {
367 399
             $location = sys_get_temp_dir();
368 400
         }
369 401
 
370 402
         $filename = tempnam($location, 'spiral');
371 403
 
372
-        if (!empty($extension)) {
404
+        if (!empty($extension))
405
+        {
373 406
             [$old, $filename] = [$filename, "{$filename}.{$extension}"];
374 407
             rename($old, $filename);
375 408
             $this->destructFiles[] = $filename;
@@ -403,15 +436,20 @@  discard block
 block discarded – undo
403 436
         $path = explode('/', $path);
404 437
         $relative = $path;
405 438
 
406
-        foreach ($from as $depth => $dir) {
439
+        foreach ($from as $depth => $dir)
440
+        {
407 441
             //Find first non-matching dir
408
-            if ($dir === $path[$depth]) {
442
+            if ($dir === $path[$depth])
443
+            {
409 444
                 //Ignore this directory
410 445
                 array_shift($relative);
411
-            } else {
446
+            }
447
+            else
448
+            {
412 449
                 //Get number of remaining dirs to $from
413 450
                 $remaining = count($from) - $depth;
414
-                if ($remaining > 1) {
451
+                if ($remaining > 1)
452
+                {
415 453
                     //Add traversals up to first matching directory
416 454
                     $padLength = (count($relative) + $remaining - 1) * -1;
417 455
                     $relative = array_pad($relative, $padLength, '..');
Please login to merge, or discard this patch.
src/Scaffolder/src/Declaration/FilterDeclaration.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
         $schema = $this->constant('SCHEMA')->getValue();
50 50
         $validates = $this->constant('VALIDATES')->getValue();
51 51
 
52
-        if (!isset($this->mapping[$type])) {
53
-            $schema[$field] = ($source ?? self::DEFAULT_SOURCE) . ':' . ($origin ?: $field);
52
+        if (!isset($this->mapping[$type])){
53
+            $schema[$field] = ($source ?? self::DEFAULT_SOURCE).':'.($origin ?: $field);
54 54
 
55 55
             $this->constant('SCHEMA')->setValue($schema);
56 56
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 
62 62
         //Source can depend on type
63 63
         $source ??= $definition['source'];
64
-        $schema[$field] = $source . ':' . ($origin ?: $field);
64
+        $schema[$field] = $source.':'.($origin ?: $field);
65 65
 
66
-        if (!empty($definition['validates'])) {
66
+        if (!empty($definition['validates'])){
67 67
             //Pre-defined validation
68 68
             $validates[$field] = $definition['validates'];
69 69
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,8 @@  discard block
 block discarded – undo
49 49
         $schema = $this->constant('SCHEMA')->getValue();
50 50
         $validates = $this->constant('VALIDATES')->getValue();
51 51
 
52
-        if (!isset($this->mapping[$type])) {
52
+        if (!isset($this->mapping[$type]))
53
+        {
53 54
             $schema[$field] = ($source ?? self::DEFAULT_SOURCE) . ':' . ($origin ?: $field);
54 55
 
55 56
             $this->constant('SCHEMA')->setValue($schema);
@@ -63,7 +64,8 @@  discard block
 block discarded – undo
63 64
         $source ??= $definition['source'];
64 65
         $schema[$field] = $source . ':' . ($origin ?: $field);
65 66
 
66
-        if (!empty($definition['validates'])) {
67
+        if (!empty($definition['validates']))
68
+        {
67 69
             //Pre-defined validation
68 70
             $validates[$field] = $definition['validates'];
69 71
         }
Please login to merge, or discard this patch.
src/Scaffolder/src/Bootloader/ScaffolderBootloader.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
         $console->addCommand(MiddlewareCommand::class);
77 77
         $console->addCommand(MigrationCommand::class, true);
78 78
 
79
-        try {
79
+        try{
80 80
             $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName();
81
-        } catch (ReflectionException $e) {
81
+        }catch (ReflectionException $e){
82 82
             $defaultNamespace = '';
83 83
         }
84 84
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
              * Base directory for generated classes, class will be automatically localed into sub directory
98 98
              * using given namespace.
99 99
              */
100
-            'directory'    => directory('app') . 'src/',
100
+            'directory'    => directory('app').'src/',
101 101
 
102 102
             /*
103 103
              * Default namespace to be applied for every generated class. By default uses Kernel namespace
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,9 +76,12 @@
 block discarded – undo
76 76
         $console->addCommand(MiddlewareCommand::class);
77 77
         $console->addCommand(MigrationCommand::class, true);
78 78
 
79
-        try {
79
+        try
80
+        {
80 81
             $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName();
81
-        } catch (ReflectionException $e) {
82
+        }
83
+        catch (ReflectionException $e)
84
+        {
82 85
             $defaultNamespace = '';
83 86
         }
84 87
 
Please login to merge, or discard this patch.
src/Models/src/AbstractEntity.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function hasField(string $name): bool
74 74
     {
75
-        if (!array_key_exists($name, $this->fields)) {
75
+        if (!array_key_exists($name, $this->fields)){
76 76
             return false;
77 77
         }
78 78
 
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function setField(string $name, $value, bool $filter = true): void
90 90
     {
91
-        if ($value instanceof ValueInterface) {
91
+        if ($value instanceof ValueInterface){
92 92
             //In case of non scalar values filters must be bypassed (check accessor compatibility?)
93 93
             $this->fields[$name] = clone $value;
94 94
 
95 95
             return;
96 96
         }
97 97
 
98
-        if (!$filter || (is_null($value) && $this->isNullable($name))) {
98
+        if (!$filter || (is_null($value) && $this->isNullable($name))){
99 99
             //Bypassing all filters
100 100
             $this->fields[$name] = $value;
101 101
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
         //Checking if field have accessor
106 106
         $accessor = $this->getMutator($name, ModelSchema::MUTATOR_ACCESSOR);
107 107
 
108
-        if ($accessor !== null) {
108
+        if ($accessor !== null){
109 109
             //Setting value thought associated accessor
110 110
             $this->thoughValue($accessor, $name, $value);
111
-        } else {
111
+        }else{
112 112
             //Setting value thought setter filter (if any)
113 113
             $this->setMutated($name, $value);
114 114
         }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     {
126 126
         $value = $this->hasField($name) ? $this->fields[$name] : $default;
127 127
 
128
-        if ($value instanceof ValueInterface || (is_null($value) && $this->isNullable($name))) {
128
+        if ($value instanceof ValueInterface || (is_null($value) && $this->isNullable($name))){
129 129
             //Direct access to value when value is accessor or null and declared as nullable
130 130
             return $value;
131 131
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         //Checking if field have accessor (decorator)
134 134
         $accessor = $this->getMutator($name, ModelSchema::MUTATOR_ACCESSOR);
135 135
 
136
-        if (!empty($accessor)) {
136
+        if (!empty($accessor)){
137 137
             return $this->fields[$name] = $this->createValue($accessor, $name, $value);
138 138
         }
139 139
 
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function setFields(iterable $fields = [], bool $all = false)
155 155
     {
156
-        if (!\is_array($fields) && !$fields instanceof Traversable) {
156
+        if (!\is_array($fields) && !$fields instanceof Traversable){
157 157
             return $this;
158 158
         }
159 159
 
160
-        foreach ($fields as $name => $value) {
161
-            if ($all || $this->isFillable($name)) {
162
-                try {
160
+        foreach ($fields as $name => $value){
161
+            if ($all || $this->isFillable($name)){
162
+                try{
163 163
                     $this->setField($name, $value, true);
164
-                } catch (AccessExceptionInterface $e) {
164
+                }catch (AccessExceptionInterface $e){
165 165
                     // We are suppressing field setting exceptions
166 166
                 }
167 167
             }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     public function getFields(bool $filter = true): array
183 183
     {
184 184
         $result = [];
185
-        foreach ($this->fields as $name => $_) {
185
+        foreach ($this->fields as $name => $_){
186 186
             $result[$name] = $this->getField($name, null, $filter);
187 187
         }
188 188
 
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
     public function getValue(): array
248 248
     {
249 249
         $result = [];
250
-        foreach ($this->fields as $field => $value) {
251
-            if ($value instanceof ValueInterface) {
250
+        foreach ($this->fields as $field => $value){
251
+            if ($value instanceof ValueInterface){
252 252
                 $result[$field] = $value->getValue();
253
-            } else {
253
+            }else{
254 254
                 $result[$field] = $value;
255 255
             }
256 256
         }
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
         $value,
333 333
         array $context = []
334 334
     ): ValueInterface {
335
-        if (!is_string($type) || !class_exists($type)) {
335
+        if (!is_string($type) || !class_exists($type)){
336 336
             throw new EntityException(
337
-                "Unable to create accessor for field `{$name}` in " . static::class
337
+                "Unable to create accessor for field `{$name}` in ".static::class
338 338
             );
339 339
         }
340 340
 
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
     {
353 353
         $getter = $this->getMutator($name, ModelSchema::MUTATOR_GETTER);
354 354
 
355
-        if ($filter && !empty($getter)) {
356
-            try {
355
+        if ($filter && !empty($getter)){
356
+            try{
357 357
                 return call_user_func($getter, $value);
358
-            } catch (Exception $e) {
358
+            }catch (Exception $e){
359 359
                 //Trying to filter null value, every filter must support it
360 360
                 return call_user_func($getter, null);
361 361
             }
@@ -373,13 +373,13 @@  discard block
 block discarded – undo
373 373
     {
374 374
         $setter = $this->getMutator($name, ModelSchema::MUTATOR_SETTER);
375 375
 
376
-        if (!empty($setter)) {
377
-            try {
376
+        if (!empty($setter)){
377
+            try{
378 378
                 $this->fields[$name] = call_user_func($setter, $value);
379
-            } catch (Exception $e) {
379
+            }catch (Exception $e){
380 380
                 //Exceptional situation, we are choosing to keep original field value
381 381
             }
382
-        } else {
382
+        }else{
383 383
             $this->fields[$name] = $value;
384 384
         }
385 385
     }
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
      */
393 393
     private function thoughValue($type, string $name, $value): void
394 394
     {
395
-        if (array_key_exists($name, $this->fields)) {
395
+        if (array_key_exists($name, $this->fields)){
396 396
             $field = $this->fields[$name];
397
-        } else {
397
+        }else{
398 398
             $field = null;
399 399
         }
400 400
 
401
-        if (empty($field) || !($field instanceof ValueInterface)) {
401
+        if (empty($field) || !($field instanceof ValueInterface)){
402 402
             //New field representation
403 403
             $field = $this->createValue($type, $name, $value);
404 404
 
Please login to merge, or discard this patch.
Braces   +61 added lines, -27 removed lines patch added patch discarded remove patch
@@ -72,7 +72,8 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function hasField(string $name): bool
74 74
     {
75
-        if (!array_key_exists($name, $this->fields)) {
75
+        if (!array_key_exists($name, $this->fields))
76
+        {
76 77
             return false;
77 78
         }
78 79
 
@@ -88,14 +89,16 @@  discard block
 block discarded – undo
88 89
      */
89 90
     public function setField(string $name, $value, bool $filter = true): void
90 91
     {
91
-        if ($value instanceof ValueInterface) {
92
+        if ($value instanceof ValueInterface)
93
+        {
92 94
             //In case of non scalar values filters must be bypassed (check accessor compatibility?)
93 95
             $this->fields[$name] = clone $value;
94 96
 
95 97
             return;
96 98
         }
97 99
 
98
-        if (!$filter || (is_null($value) && $this->isNullable($name))) {
100
+        if (!$filter || (is_null($value) && $this->isNullable($name)))
101
+        {
99 102
             //Bypassing all filters
100 103
             $this->fields[$name] = $value;
101 104
 
@@ -105,10 +108,13 @@  discard block
 block discarded – undo
105 108
         //Checking if field have accessor
106 109
         $accessor = $this->getMutator($name, ModelSchema::MUTATOR_ACCESSOR);
107 110
 
108
-        if ($accessor !== null) {
111
+        if ($accessor !== null)
112
+        {
109 113
             //Setting value thought associated accessor
110 114
             $this->thoughValue($accessor, $name, $value);
111
-        } else {
115
+        }
116
+        else
117
+        {
112 118
             //Setting value thought setter filter (if any)
113 119
             $this->setMutated($name, $value);
114 120
         }
@@ -125,7 +131,8 @@  discard block
 block discarded – undo
125 131
     {
126 132
         $value = $this->hasField($name) ? $this->fields[$name] : $default;
127 133
 
128
-        if ($value instanceof ValueInterface || (is_null($value) && $this->isNullable($name))) {
134
+        if ($value instanceof ValueInterface || (is_null($value) && $this->isNullable($name)))
135
+        {
129 136
             //Direct access to value when value is accessor or null and declared as nullable
130 137
             return $value;
131 138
         }
@@ -133,7 +140,8 @@  discard block
 block discarded – undo
133 140
         //Checking if field have accessor (decorator)
134 141
         $accessor = $this->getMutator($name, ModelSchema::MUTATOR_ACCESSOR);
135 142
 
136
-        if (!empty($accessor)) {
143
+        if (!empty($accessor))
144
+        {
137 145
             return $this->fields[$name] = $this->createValue($accessor, $name, $value);
138 146
         }
139 147
 
@@ -153,15 +161,21 @@  discard block
 block discarded – undo
153 161
      */
154 162
     public function setFields(iterable $fields = [], bool $all = false)
155 163
     {
156
-        if (!\is_array($fields) && !$fields instanceof Traversable) {
164
+        if (!\is_array($fields) && !$fields instanceof Traversable)
165
+        {
157 166
             return $this;
158 167
         }
159 168
 
160
-        foreach ($fields as $name => $value) {
161
-            if ($all || $this->isFillable($name)) {
162
-                try {
169
+        foreach ($fields as $name => $value)
170
+        {
171
+            if ($all || $this->isFillable($name))
172
+            {
173
+                try
174
+                {
163 175
                     $this->setField($name, $value, true);
164
-                } catch (AccessExceptionInterface $e) {
176
+                }
177
+                catch (AccessExceptionInterface $e)
178
+                {
165 179
                     // We are suppressing field setting exceptions
166 180
                 }
167 181
             }
@@ -182,7 +196,8 @@  discard block
 block discarded – undo
182 196
     public function getFields(bool $filter = true): array
183 197
     {
184 198
         $result = [];
185
-        foreach ($this->fields as $name => $_) {
199
+        foreach ($this->fields as $name => $_)
200
+        {
186 201
             $result[$name] = $this->getField($name, null, $filter);
187 202
         }
188 203
 
@@ -247,10 +262,14 @@  discard block
 block discarded – undo
247 262
     public function getValue(): array
248 263
     {
249 264
         $result = [];
250
-        foreach ($this->fields as $field => $value) {
251
-            if ($value instanceof ValueInterface) {
265
+        foreach ($this->fields as $field => $value)
266
+        {
267
+            if ($value instanceof ValueInterface)
268
+            {
252 269
                 $result[$field] = $value->getValue();
253
-            } else {
270
+            }
271
+            else
272
+            {
254 273
                 $result[$field] = $value;
255 274
             }
256 275
         }
@@ -332,7 +351,8 @@  discard block
 block discarded – undo
332 351
         $value,
333 352
         array $context = []
334 353
     ): ValueInterface {
335
-        if (!is_string($type) || !class_exists($type)) {
354
+        if (!is_string($type) || !class_exists($type))
355
+        {
336 356
             throw new EntityException(
337 357
                 "Unable to create accessor for field `{$name}` in " . static::class
338 358
             );
@@ -352,10 +372,14 @@  discard block
 block discarded – undo
352 372
     {
353 373
         $getter = $this->getMutator($name, ModelSchema::MUTATOR_GETTER);
354 374
 
355
-        if ($filter && !empty($getter)) {
356
-            try {
375
+        if ($filter && !empty($getter))
376
+        {
377
+            try
378
+            {
357 379
                 return call_user_func($getter, $value);
358
-            } catch (Exception $e) {
380
+            }
381
+            catch (Exception $e)
382
+            {
359 383
                 //Trying to filter null value, every filter must support it
360 384
                 return call_user_func($getter, null);
361 385
             }
@@ -373,13 +397,19 @@  discard block
 block discarded – undo
373 397
     {
374 398
         $setter = $this->getMutator($name, ModelSchema::MUTATOR_SETTER);
375 399
 
376
-        if (!empty($setter)) {
377
-            try {
400
+        if (!empty($setter))
401
+        {
402
+            try
403
+            {
378 404
                 $this->fields[$name] = call_user_func($setter, $value);
379
-            } catch (Exception $e) {
405
+            }
406
+            catch (Exception $e)
407
+            {
380 408
                 //Exceptional situation, we are choosing to keep original field value
381 409
             }
382
-        } else {
410
+        }
411
+        else
412
+        {
383 413
             $this->fields[$name] = $value;
384 414
         }
385 415
     }
@@ -392,13 +422,17 @@  discard block
 block discarded – undo
392 422
      */
393 423
     private function thoughValue($type, string $name, $value): void
394 424
     {
395
-        if (array_key_exists($name, $this->fields)) {
425
+        if (array_key_exists($name, $this->fields))
426
+        {
396 427
             $field = $this->fields[$name];
397
-        } else {
428
+        }
429
+        else
430
+        {
398 431
             $field = null;
399 432
         }
400 433
 
401
-        if (empty($field) || !($field instanceof ValueInterface)) {
434
+        if (empty($field) || !($field instanceof ValueInterface))
435
+        {
402 436
             //New field representation
403 437
             $field = $this->createValue($type, $name, $value);
404 438
 
Please login to merge, or discard this patch.
src/Validation/src/RuleParser.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $rules = is_array($rules) ? $rules : [$rules];
33 33
 
34
-        foreach ($rules as $rule) {
35
-            if ($rule instanceof Closure) {
34
+        foreach ($rules as $rule){
35
+            if ($rule instanceof Closure){
36 36
                 yield null => $rule;
37 37
                 continue;
38 38
             }
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function parseCheck($chunk)
48 48
     {
49
-        if (is_string($chunk)) {
49
+        if (is_string($chunk)){
50 50
             $function = str_replace('::', ':', $chunk);
51
-        } else {
52
-            if (!is_array($chunk) || !isset($chunk[0])) {
51
+        }else{
52
+            if (!is_array($chunk) || !isset($chunk[0])){
53 53
                 throw new ParserException('Validation rule does not define any check.');
54 54
             }
55 55
 
56 56
             $function = $chunk[0];
57 57
         }
58 58
 
59
-        if (is_string($function)) {
59
+        if (is_string($function)){
60 60
             return str_replace('::', ':', $function);
61 61
         }
62 62
 
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function parseArgs($chunk): array
70 70
     {
71
-        if (!is_array($chunk)) {
71
+        if (!is_array($chunk)){
72 72
             return [];
73 73
         }
74 74
 
75
-        foreach (self::ARGUMENTS as $index) {
76
-            if (isset($chunk[$index])) {
75
+        foreach (self::ARGUMENTS as $index){
76
+            if (isset($chunk[$index])){
77 77
                 return $chunk[$index];
78 78
             }
79 79
         }
80 80
 
81 81
         unset($chunk[0]);
82
-        foreach (array_merge(self::MESSAGES, self::CONDITIONS) as $index) {
82
+        foreach (array_merge(self::MESSAGES, self::CONDITIONS) as $index){
83 83
             unset($chunk[$index]);
84 84
         }
85 85
 
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function parseMessage($chunk): ?string
93 93
     {
94
-        if (!is_array($chunk)) {
94
+        if (!is_array($chunk)){
95 95
             return null;
96 96
         }
97 97
 
98
-        foreach (self::MESSAGES as $index) {
99
-            if (isset($chunk[$index])) {
98
+        foreach (self::MESSAGES as $index){
99
+            if (isset($chunk[$index])){
100 100
                 return $chunk[$index];
101 101
             }
102 102
         }
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function parseConditions($chunk): array
111 111
     {
112
-        foreach (self::CONDITIONS as $index) {
113
-            if (isset($chunk[$index])) {
112
+        foreach (self::CONDITIONS as $index){
113
+            if (isset($chunk[$index])){
114 114
                 $conditions = [];
115
-                foreach ((array)$chunk[$index] as $key => $value) {
116
-                    if (is_numeric($key)) {
115
+                foreach ((array)$chunk[$index] as $key => $value){
116
+                    if (is_numeric($key)){
117 117
                         $conditions[$value] = [];
118
-                    } else {
118
+                    }else{
119 119
                         $conditions[$key] = (array)$value;
120 120
                     }
121 121
                 }
Please login to merge, or discard this patch.
Braces   +38 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,8 +31,10 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $rules = is_array($rules) ? $rules : [$rules];
33 33
 
34
-        foreach ($rules as $rule) {
35
-            if ($rule instanceof Closure) {
34
+        foreach ($rules as $rule)
35
+        {
36
+            if ($rule instanceof Closure)
37
+            {
36 38
                 yield null => $rule;
37 39
                 continue;
38 40
             }
@@ -46,17 +48,22 @@  discard block
 block discarded – undo
46 48
      */
47 49
     public function parseCheck($chunk)
48 50
     {
49
-        if (is_string($chunk)) {
51
+        if (is_string($chunk))
52
+        {
50 53
             $function = str_replace('::', ':', $chunk);
51
-        } else {
52
-            if (!is_array($chunk) || !isset($chunk[0])) {
54
+        }
55
+        else
56
+        {
57
+            if (!is_array($chunk) || !isset($chunk[0]))
58
+            {
53 59
                 throw new ParserException('Validation rule does not define any check.');
54 60
             }
55 61
 
56 62
             $function = $chunk[0];
57 63
         }
58 64
 
59
-        if (is_string($function)) {
65
+        if (is_string($function))
66
+        {
60 67
             return str_replace('::', ':', $function);
61 68
         }
62 69
 
@@ -68,18 +75,22 @@  discard block
 block discarded – undo
68 75
      */
69 76
     public function parseArgs($chunk): array
70 77
     {
71
-        if (!is_array($chunk)) {
78
+        if (!is_array($chunk))
79
+        {
72 80
             return [];
73 81
         }
74 82
 
75
-        foreach (self::ARGUMENTS as $index) {
76
-            if (isset($chunk[$index])) {
83
+        foreach (self::ARGUMENTS as $index)
84
+        {
85
+            if (isset($chunk[$index]))
86
+            {
77 87
                 return $chunk[$index];
78 88
             }
79 89
         }
80 90
 
81 91
         unset($chunk[0]);
82
-        foreach (array_merge(self::MESSAGES, self::CONDITIONS) as $index) {
92
+        foreach (array_merge(self::MESSAGES, self::CONDITIONS) as $index)
93
+        {
83 94
             unset($chunk[$index]);
84 95
         }
85 96
 
@@ -91,12 +102,15 @@  discard block
 block discarded – undo
91 102
      */
92 103
     public function parseMessage($chunk): ?string
93 104
     {
94
-        if (!is_array($chunk)) {
105
+        if (!is_array($chunk))
106
+        {
95 107
             return null;
96 108
         }
97 109
 
98
-        foreach (self::MESSAGES as $index) {
99
-            if (isset($chunk[$index])) {
110
+        foreach (self::MESSAGES as $index)
111
+        {
112
+            if (isset($chunk[$index]))
113
+            {
100 114
                 return $chunk[$index];
101 115
             }
102 116
         }
@@ -109,13 +123,19 @@  discard block
 block discarded – undo
109 123
      */
110 124
     public function parseConditions($chunk): array
111 125
     {
112
-        foreach (self::CONDITIONS as $index) {
113
-            if (isset($chunk[$index])) {
126
+        foreach (self::CONDITIONS as $index)
127
+        {
128
+            if (isset($chunk[$index]))
129
+            {
114 130
                 $conditions = [];
115
-                foreach ((array)$chunk[$index] as $key => $value) {
116
-                    if (is_numeric($key)) {
131
+                foreach ((array)$chunk[$index] as $key => $value)
132
+                {
133
+                    if (is_numeric($key))
134
+                    {
117 135
                         $conditions[$value] = [];
118
-                    } else {
136
+                    }
137
+                    else
138
+                    {
119 139
                         $conditions[$key] = (array)$value;
120 140
                     }
121 141
                 }
Please login to merge, or discard this patch.
src/Validation/src/ValidationProvider.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         ValidatorConfig $config,
43 43
         ParserInterface $parser = null,
44 44
         FactoryInterface $factory = null
45
-    ) {
45
+    ){
46 46
         $this->config = $config;
47 47
         $this->parser = $parser ?? new RuleParser();
48 48
         $this->factory = $factory ?? new Container();
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function getRules($rules): Generator
78 78
     {
79
-        foreach ($this->parser->split($rules) as $id => $rule) {
80
-            if (empty($id) || $rule instanceof Closure) {
79
+        foreach ($this->parser->split($rules) as $id => $rule){
80
+            if (empty($id) || $rule instanceof Closure){
81 81
                 yield new CallableRule($rule);
82 82
                 continue;
83 83
             }
84 84
 
85 85
             // fetch from cache
86
-            if (isset($this->rules[$id])) {
86
+            if (isset($this->rules[$id])){
87 87
                 yield $this->rules[$id];
88 88
                 continue;
89 89
             }
@@ -123,17 +123,17 @@  discard block
 block discarded – undo
123 123
         $args = $this->parser->parseArgs($rule);
124 124
         $message = $this->parser->parseMessage($rule);
125 125
 
126
-        if (!is_array($check)) {
126
+        if (!is_array($check)){
127 127
             return new CallableRule($check, $args, $message);
128 128
         }
129 129
 
130
-        if (is_string($check[0]) && $this->config->hasChecker($check[0])) {
130
+        if (is_string($check[0]) && $this->config->hasChecker($check[0])){
131 131
             $check[0] = $this->config->getChecker($check[0])->resolve($this->factory);
132 132
 
133 133
             return new CheckerRule($check[0], $check[1], $args, $message);
134 134
         }
135 135
 
136
-        if (!is_object($check[0])) {
136
+        if (!is_object($check[0])){
137 137
             $check[0] = (new Autowire($check[0]))->resolve($this->factory);
138 138
         }
139 139
 
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
      */
147 147
     protected function makeConditions(array $conditions): ?SplObjectStorage
148 148
     {
149
-        if (empty($conditions)) {
149
+        if (empty($conditions)){
150 150
             return null;
151 151
         }
152 152
 
153 153
         $storage = new SplObjectStorage();
154
-        foreach ($conditions as $condition => $options) {
154
+        foreach ($conditions as $condition => $options){
155 155
             $condition = $this->config->resolveAlias($condition);
156 156
 
157
-            if ($this->config->hasCondition($condition)) {
157
+            if ($this->config->hasCondition($condition)){
158 158
                 $autowire = $this->config->getCondition($condition);
159
-            } else {
159
+            }else{
160 160
                 $autowire = new Autowire($condition);
161 161
             }
162 162
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -76,14 +76,17 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function getRules($rules): Generator
78 78
     {
79
-        foreach ($this->parser->split($rules) as $id => $rule) {
80
-            if (empty($id) || $rule instanceof Closure) {
79
+        foreach ($this->parser->split($rules) as $id => $rule)
80
+        {
81
+            if (empty($id) || $rule instanceof Closure)
82
+            {
81 83
                 yield new CallableRule($rule);
82 84
                 continue;
83 85
             }
84 86
 
85 87
             // fetch from cache
86
-            if (isset($this->rules[$id])) {
88
+            if (isset($this->rules[$id]))
89
+            {
87 90
                 yield $this->rules[$id];
88 91
                 continue;
89 92
             }
@@ -123,17 +126,20 @@  discard block
 block discarded – undo
123 126
         $args = $this->parser->parseArgs($rule);
124 127
         $message = $this->parser->parseMessage($rule);
125 128
 
126
-        if (!is_array($check)) {
129
+        if (!is_array($check))
130
+        {
127 131
             return new CallableRule($check, $args, $message);
128 132
         }
129 133
 
130
-        if (is_string($check[0]) && $this->config->hasChecker($check[0])) {
134
+        if (is_string($check[0]) && $this->config->hasChecker($check[0]))
135
+        {
131 136
             $check[0] = $this->config->getChecker($check[0])->resolve($this->factory);
132 137
 
133 138
             return new CheckerRule($check[0], $check[1], $args, $message);
134 139
         }
135 140
 
136
-        if (!is_object($check[0])) {
141
+        if (!is_object($check[0]))
142
+        {
137 143
             $check[0] = (new Autowire($check[0]))->resolve($this->factory);
138 144
         }
139 145
 
@@ -146,17 +152,22 @@  discard block
 block discarded – undo
146 152
      */
147 153
     protected function makeConditions(array $conditions): ?SplObjectStorage
148 154
     {
149
-        if (empty($conditions)) {
155
+        if (empty($conditions))
156
+        {
150 157
             return null;
151 158
         }
152 159
 
153 160
         $storage = new SplObjectStorage();
154
-        foreach ($conditions as $condition => $options) {
161
+        foreach ($conditions as $condition => $options)
162
+        {
155 163
             $condition = $this->config->resolveAlias($condition);
156 164
 
157
-            if ($this->config->hasCondition($condition)) {
165
+            if ($this->config->hasCondition($condition))
166
+            {
158 167
                 $autowire = $this->config->getCondition($condition);
159
-            } else {
168
+            }
169
+            else
170
+            {
160 171
                 $autowire = new Autowire($condition);
161 172
             }
162 173
 
Please login to merge, or discard this patch.
src/Validation/src/Checker/DatetimeChecker.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function format($value, string $format): bool
80 80
     {
81
-        if (!$this->isApplicableValue($value)) {
81
+        if (!$this->isApplicableValue($value)){
82 82
             return false;
83 83
         }
84 84
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function timezone($value): bool
106 106
     {
107
-        if (!is_scalar($value)) {
107
+        if (!is_scalar($value)){
108 108
             return false;
109 109
         }
110 110
 
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
      */
137 137
     private function now(): ?DateTimeInterface
138 138
     {
139
-        try {
139
+        try{
140 140
             return $this->date($this->now ?: 'now');
141
-        } catch (Throwable $e) {
141
+        }catch (Throwable $e){
142 142
             //here's the fail;
143 143
         }
144 144
 
@@ -150,25 +150,25 @@  discard block
 block discarded – undo
150 150
      */
151 151
     private function date($value): ?DateTimeInterface
152 152
     {
153
-        if (is_callable($value)) {
153
+        if (is_callable($value)){
154 154
             $value = $value();
155 155
         }
156 156
 
157
-        if ($value instanceof DateTimeInterface) {
157
+        if ($value instanceof DateTimeInterface){
158 158
             return $value;
159 159
         }
160 160
 
161
-        if (!$this->isApplicableValue($value)) {
161
+        if (!$this->isApplicableValue($value)){
162 162
             return null;
163 163
         }
164 164
 
165
-        try {
166
-            if (!$value) {
165
+        try{
166
+            if (!$value){
167 167
                 $value = '0';
168 168
             }
169 169
 
170 170
             return new DateTimeImmutable(is_numeric($value) ? sprintf('@%d', $value) : trim($value));
171
-        } catch (Throwable $e) {
171
+        }catch (Throwable $e){
172 172
             //here's the fail;
173 173
         }
174 174
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
     private function fromField(string $field): ?DateTimeInterface
187 187
     {
188 188
         $before = $this->getValidator()->getValue($field);
189
-        if ($before !== null) {
189
+        if ($before !== null){
190 190
             return $this->date($before);
191 191
         }
192 192
 
Please login to merge, or discard this patch.
Braces   +24 added lines, -11 removed lines patch added patch discarded remove patch
@@ -78,7 +78,8 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function format($value, string $format): bool
80 80
     {
81
-        if (!$this->isApplicableValue($value)) {
81
+        if (!$this->isApplicableValue($value))
82
+        {
82 83
             return false;
83 84
         }
84 85
 
@@ -104,7 +105,8 @@  discard block
 block discarded – undo
104 105
      */
105 106
     public function timezone($value): bool
106 107
     {
107
-        if (!is_scalar($value)) {
108
+        if (!is_scalar($value))
109
+        {
108 110
             return false;
109 111
         }
110 112
 
@@ -136,9 +138,12 @@  discard block
 block discarded – undo
136 138
      */
137 139
     private function now(): ?DateTimeInterface
138 140
     {
139
-        try {
141
+        try
142
+        {
140 143
             return $this->date($this->now ?: 'now');
141
-        } catch (Throwable $e) {
144
+        }
145
+        catch (Throwable $e)
146
+        {
142 147
             //here's the fail;
143 148
         }
144 149
 
@@ -150,25 +155,32 @@  discard block
 block discarded – undo
150 155
      */
151 156
     private function date($value): ?DateTimeInterface
152 157
     {
153
-        if (is_callable($value)) {
158
+        if (is_callable($value))
159
+        {
154 160
             $value = $value();
155 161
         }
156 162
 
157
-        if ($value instanceof DateTimeInterface) {
163
+        if ($value instanceof DateTimeInterface)
164
+        {
158 165
             return $value;
159 166
         }
160 167
 
161
-        if (!$this->isApplicableValue($value)) {
168
+        if (!$this->isApplicableValue($value))
169
+        {
162 170
             return null;
163 171
         }
164 172
 
165
-        try {
166
-            if (!$value) {
173
+        try
174
+        {
175
+            if (!$value)
176
+            {
167 177
                 $value = '0';
168 178
             }
169 179
 
170 180
             return new DateTimeImmutable(is_numeric($value) ? sprintf('@%d', $value) : trim($value));
171
-        } catch (Throwable $e) {
181
+        }
182
+        catch (Throwable $e)
183
+        {
172 184
             //here's the fail;
173 185
         }
174 186
 
@@ -186,7 +198,8 @@  discard block
 block discarded – undo
186 198
     private function fromField(string $field): ?DateTimeInterface
187 199
     {
188 200
         $before = $this->getValidator()->getValue($field);
189
-        if ($before !== null) {
201
+        if ($before !== null)
202
+        {
190 203
             return $this->date($before);
191 204
         }
192 205
 
Please login to merge, or discard this patch.