Passed
Push — master ( 77392d...e0a3bd )
by Kirill
08:16 queued 11s
created
src/Filters/src/SchemaBuilder.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
     protected function buildMap(ReflectionEntity $filter): array
71 71
     {
72 72
         $schema = $filter->getProperty('schema', true);
73
-        if (empty($schema)) {
73
+        if (empty($schema)){
74 74
             throw new SchemaException("Filter `{$filter->getName()}` does not define any schema");
75 75
         }
76 76
 
77 77
         $result = [];
78
-        foreach ($schema as $field => $definition) {
78
+        foreach ($schema as $field => $definition){
79 79
             $optional = false;
80 80
 
81 81
             // short definition
82
-            if (is_string($definition)) {
82
+            if (is_string($definition)){
83 83
                 // simple scalar field definition
84
-                if (!class_exists($definition)) {
84
+                if (!class_exists($definition)){
85 85
                     [$source, $origin] = $this->parseDefinition($field, $definition);
86 86
                     $result[$field] = [
87 87
                         FilterProvider::SOURCE => $source,
@@ -102,25 +102,25 @@  discard block
 block discarded – undo
102 102
                 continue;
103 103
             }
104 104
 
105
-            if (!is_array($definition) || count($definition) === 0) {
105
+            if (!is_array($definition) || count($definition) === 0){
106 106
                 throw new SchemaException(
107 107
                     "Invalid schema definition at `{$filter->getName()}`->`{$field}`"
108 108
                 );
109 109
             }
110 110
 
111 111
             // complex definition
112
-            if (!empty($definition[self::ORIGIN])) {
112
+            if (!empty($definition[self::ORIGIN])){
113 113
                 $origin = $definition[self::ORIGIN];
114 114
 
115 115
                 // [class, 'data:something.*'] vs [class, 'data:something']
116 116
                 $iterate = strpos($origin, '.*') !== false || !empty($definition[self::ITERATE]);
117 117
                 $origin = rtrim($origin, '.*');
118
-            } else {
118
+            }else{
119 119
                 $origin = $field;
120 120
                 $iterate = true;
121 121
             }
122 122
 
123
-            if (!empty($definition[self::OPTIONAL]) && $definition[self::OPTIONAL]) {
123
+            if (!empty($definition[self::OPTIONAL]) && $definition[self::OPTIONAL]){
124 124
                 $optional = true;
125 125
             }
126 126
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                 FilterProvider::OPTIONAL => $optional,
134 134
             ];
135 135
 
136
-            if ($iterate) {
136
+            if ($iterate){
137 137
                 [$source, $origin] = $this->parseDefinition($field, $definition[self::ITERATE] ?? $origin);
138 138
 
139 139
                 $map[FilterProvider::ITERATE_SOURCE] = $source;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     private function parseDefinition(string $field, string $definition): array
161 161
     {
162
-        if (strpos($definition, ':') === false) {
162
+        if (strpos($definition, ':') === false){
163 163
             return ['data', $definition ?? $field];
164 164
         }
165 165
 
Please login to merge, or discard this patch.
src/Filters/src/Filter.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         array $schema,
91 91
         ValidatorInterface $validator,
92 92
         ErrorMapper $errorMapper
93
-    ) {
93
+    ){
94 94
         parent::__construct($data, $schema);
95 95
 
96 96
         $this->mappings = $schema[FilterProvider::MAPPING] ?? [];
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function getErrors(): array
153 153
     {
154
-        if ($this->errors === null) {
154
+        if ($this->errors === null){
155 155
             $this->errors = [];
156
-            foreach ($this->validator->withData($this)->getErrors() as $field => $error) {
157
-                if (is_string($error) && Translator::isMessage($error)) {
156
+            foreach ($this->validator->withData($this)->getErrors() as $field => $error){
157
+                if (is_string($error) && Translator::isMessage($error)){
158 158
                     // translate error message
159 159
                     $error = $this->say($error);
160 160
                 }
@@ -195,32 +195,32 @@  discard block
 block discarded – undo
195 195
      */
196 196
     protected function validateNested(array $errors): array
197 197
     {
198
-        foreach ($this->getFields(false) as $index => $value) {
199
-            if (isset($errors[$index])) {
198
+        foreach ($this->getFields(false) as $index => $value){
199
+            if (isset($errors[$index])){
200 200
                 //Invalid on parent level
201 201
                 continue;
202 202
             }
203 203
 
204
-            if ($value instanceof FilterInterface) {
205
-                if ($this->isOptional($index) && !$this->hasBeenPassed($index)) {
204
+            if ($value instanceof FilterInterface){
205
+                if ($this->isOptional($index) && !$this->hasBeenPassed($index)){
206 206
                     continue;
207 207
                 }
208 208
 
209
-                if (!$value->isValid()) {
209
+                if (!$value->isValid()){
210 210
                     $errors[$index] = $value->getErrors();
211 211
                     continue;
212 212
                 }
213 213
             }
214 214
 
215 215
             //Array of nested entities for validation
216
-            if (is_iterable($value)) {
217
-                foreach ($value as $nIndex => $nValue) {
218
-                    if ($nValue instanceof FilterInterface) {
219
-                        if ($this->isOptional($nIndex) && !$this->hasBeenPassed($nIndex)) {
216
+            if (is_iterable($value)){
217
+                foreach ($value as $nIndex => $nValue){
218
+                    if ($nValue instanceof FilterInterface){
219
+                        if ($this->isOptional($nIndex) && !$this->hasBeenPassed($nIndex)){
220 220
                             continue;
221 221
                         }
222 222
 
223
-                        if (!$nValue->isValid()) {
223
+                        if (!$nValue->isValid()){
224 224
                             $errors[$index][$nIndex] = $nValue->getErrors();
225 225
                         }
226 226
                     }
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
     {
255 255
         $value = $this->getField((string)$field);
256 256
 
257
-        if ($value === null) {
257
+        if ($value === null){
258 258
             return false;
259 259
         }
260 260
 
261
-        if ($value instanceof FilterInterface) {
261
+        if ($value instanceof FilterInterface){
262 262
             return $value->getValue() !== [];
263 263
         }
264 264
 
Please login to merge, or discard this patch.
src/Framework/Command/Migrate/MigrateCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function perform(): void
28 28
     {
29
-        if (!$this->verifyEnvironment()) {
29
+        if (!$this->verifyEnvironment()){
30 30
             return;
31 31
         }
32 32
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $found = false;
36 36
         $count = $this->option('one') ? 1 : PHP_INT_MAX;
37 37
 
38
-        while ($count > 0 && ($migration = $this->migrator->run())) {
38
+        while ($count > 0 && ($migration = $this->migrator->run())){
39 39
             $found = true;
40 40
             $count--;
41 41
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
             );
46 46
         }
47 47
 
48
-        if (!$found) {
48
+        if (!$found){
49 49
             $this->writeln('<fg=red>No outstanding migrations were found.</fg=red>');
50 50
         }
51 51
     }
Please login to merge, or discard this patch.
src/Framework/Command/Migrate/StatusCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
     {
31 31
         $this->migrator->configure();
32 32
 
33
-        if (empty($this->migrator->getMigrations())) {
33
+        if (empty($this->migrator->getMigrations())){
34 34
             $this->writeln('<comment>No migrations were found.</comment>');
35 35
 
36 36
             return;
37 37
         }
38 38
 
39 39
         $table = $this->table(['Migration', 'Created at', 'Executed at']);
40
-        foreach ($this->migrator->getMigrations() as $migration) {
40
+        foreach ($this->migrator->getMigrations() as $migration){
41 41
             $state = $migration->getState();
42 42
 
43 43
             $table->addRow(
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
                     $state->getTimeCreated()->format('Y-m-d H:i:s'),
47 47
                     $state->getStatus() == State::STATUS_PENDING
48 48
                         ? self::PENDING
49
-                        : '<info>' . $state->getTimeExecuted()->format('Y-m-d H:i:s') . '</info>',
49
+                        : '<info>'.$state->getTimeExecuted()->format('Y-m-d H:i:s').'</info>',
50 50
                 ]
51 51
             );
52 52
         }
Please login to merge, or discard this patch.
src/Framework/Command/Migrate/RollbackCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function perform(): void
28 28
     {
29
-        if (!$this->verifyEnvironment()) {
29
+        if (!$this->verifyEnvironment()){
30 30
             //Making sure we can safely migrate in this environment
31 31
             return;
32 32
         }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
         $found = false;
37 37
         $count = !$this->option('all') ? 1 : PHP_INT_MAX;
38
-        while ($count > 0 && ($migration = $this->migrator->rollback())) {
38
+        while ($count > 0 && ($migration = $this->migrator->rollback())){
39 39
             $found = true;
40 40
             $count--;
41 41
             $this->sprintf(
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             );
45 45
         }
46 46
 
47
-        if (!$found) {
47
+        if (!$found){
48 48
             $this->writeln('<fg=red>No executed migrations were found.</fg=red>');
49 49
         }
50 50
     }
Please login to merge, or discard this patch.
src/Framework/Command/Cycle/MigrateCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
     ): void {
53 53
         $migrator->configure();
54 54
 
55
-        foreach ($migrator->getMigrations() as $migration) {
56
-            if ($migration->getState()->getStatus() !== Status::STATUS_EXECUTED) {
55
+        foreach ($migrator->getMigrations() as $migration){
56
+            if ($migration->getState()->getStatus() !== Status::STATUS_EXECUTED){
57 57
                 $this->writeln('<fg=red>Outstanding migrations found, run `migrate` first.</fg=red>');
58 58
                 return;
59 59
             }
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
         );
68 68
         $schemaCompiler->toMemory($memory);
69 69
 
70
-        if ($show->hasChanges()) {
70
+        if ($show->hasChanges()){
71 71
             (new Compiler())->compile($registry, [$migrations]);
72 72
 
73
-            if ($this->option('run')) {
73
+            if ($this->option('run')){
74 74
                 $console->run('migrate', [], $this->output);
75 75
             }
76 76
         }
Please login to merge, or discard this patch.
tests/Framework/ConsoleTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
     private function cleanupMigrations(): void
33 33
     {
34 34
         $fs = new Files();
35
-        if ($fs->isDirectory(__DIR__ . '/../app/migrations')) {
36
-            $fs->deleteDirectory(__DIR__ . '/../app/migrations');
35
+        if ($fs->isDirectory(__DIR__.'/../app/migrations')){
36
+            $fs->deleteDirectory(__DIR__.'/../app/migrations');
37 37
         }
38 38
     }
39 39
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $fs = new Files();
47 47
         $runtime = $this->app->get(DirectoriesInterface::class)->get('runtime');
48 48
 
49
-        if ($fs->isDirectory($runtime)) {
49
+        if ($fs->isDirectory($runtime)){
50 50
             $fs->deleteDirectory($runtime);
51 51
         }
52 52
     }
Please login to merge, or discard this patch.