Passed
Pull Request — master (#383)
by Valentin
06:35
created
src/DataGrid/tests/GridFactoryTest.php 1 patch
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -241,7 +241,8 @@  discard block
 block discarded – undo
241 241
         $expected,
242 242
         string $expectedException = null
243 243
     ): void {
244
-        if ($expectedException !== null) {
244
+        if ($expectedException !== null)
245
+        {
245 246
             $this->expectException($expectedException);
246 247
         }
247 248
 
@@ -300,7 +301,8 @@  discard block
 block discarded – undo
300 301
             new Gte('price', new Value\FloatValue())
301 302
         );
302 303
         $schema->addWrappedFilters(
303
-            static function (FilterInterface ...$filters) {
304
+            static function (FilterInterface ...$filters)
305
+            {
304 306
                 return new Any(...$filters);
305 307
             },
306 308
             'size',
@@ -372,15 +374,18 @@  discard block
 block discarded – undo
372 374
     private function paginatorInput(int $page = null, int $limit = null): array
373 375
     {
374 376
         $result = [];
375
-        if ($page === null && $limit === null) {
377
+        if ($page === null && $limit === null)
378
+        {
376 379
             return $result;
377 380
         }
378 381
 
379
-        if ($page !== null) {
382
+        if ($page !== null)
383
+        {
380 384
             $result['page'] = $page;
381 385
         }
382 386
 
383
-        if ($limit !== null) {
387
+        if ($limit !== null)
388
+        {
384 389
             $result['limit'] = $limit;
385 390
         }
386 391
 
Please login to merge, or discard this patch.
src/DataGrid/tests/Fixture/WrapWriter.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@
 block discarded – undo
21 21
      */
22 22
     public function write($source, SpecificationInterface $specification, Compiler $compiler)
23 23
     {
24
-        if (is_array($source)) {
24
+        if (is_array($source))
25
+        {
25 26
             $source[] = $specification;
26 27
         }
27 28
 
Please login to merge, or discard this patch.
src/DataGrid/src/GridFactory.php 1 patch
Braces   +28 added lines, -14 removed lines patch added patch discarded remove patch
@@ -108,7 +108,8 @@  discard block
 block discarded – undo
108 108
         ['view' => $view, 'source' => $source] = $this->applySorters($view, $source, $schema);
109 109
         ['view' => $view, 'source' => $source] = $this->applyPaginator($view, $source, $schema);
110 110
 
111
-        if (!is_iterable($source)) {
111
+        if (!is_iterable($source))
112
+        {
112 113
             throw new GridViewException('GridView expects the source to be iterable after all.');
113 114
         }
114 115
 
@@ -127,18 +128,22 @@  discard block
 block discarded – undo
127 128
     {
128 129
         $values = [];
129 130
         $filters = [];
130
-        foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) {
131
-            if ($schema->hasFilter($name)) {
131
+        foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value)
132
+        {
133
+            if ($schema->hasFilter($name))
134
+            {
132 135
                 $filter = $schema->getFilter($name)->withValue($value);
133 136
 
134
-                if ($filter !== null) {
137
+                if ($filter !== null)
138
+                {
135 139
                     $filters[$name] = $filter;
136 140
                     $values[$name] = $filter->getValue();
137 141
                 }
138 142
             }
139 143
         }
140 144
 
141
-        foreach ($schema->wrapFilters($filters) as $filter) {
145
+        foreach ($schema->wrapFilters($filters) as $filter)
146
+        {
142 147
             $source = $this->compiler->compile($source, $filter);
143 148
         }
144 149
 
@@ -147,7 +152,8 @@  discard block
 block discarded – undo
147 152
 
148 153
     protected function applyCounter(GridInterface $view, $source, GridSchema $schema): array
149 154
     {
150
-        if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) {
155
+        if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT))
156
+        {
151 157
             $view = $view->withOption(GridInterface::COUNT, ($this->count)($source));
152 158
         }
153 159
 
@@ -165,11 +171,14 @@  discard block
 block discarded – undo
165 171
     protected function getSorters($source, GridSchema $schema): array
166 172
     {
167 173
         $sorters = [];
168
-        foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) {
169
-            if ($schema->hasSorter($name)) {
174
+        foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value)
175
+        {
176
+            if ($schema->hasSorter($name))
177
+            {
170 178
                 $sorter = $schema->getSorter($name)->withDirection($value);
171 179
 
172
-                if ($sorter !== null) {
180
+                if ($sorter !== null)
181
+                {
173 182
                     $source = $this->compiler->compile($source, $sorter);
174 183
                     $sorters[$name] = $sorter->getValue();
175 184
                 }
@@ -181,7 +190,8 @@  discard block
 block discarded – undo
181 190
 
182 191
     protected function applyPaginator(GridInterface $view, $source, GridSchema $schema): array
183 192
     {
184
-        if ($schema->getPaginator() !== null) {
193
+        if ($schema->getPaginator() !== null)
194
+        {
185 195
             ['source' => $source, 'paginator' => $paginator] = $this->getPaginator($source, $schema);
186 196
             $view = $view->withOption(GridInterface::PAGINATOR, $paginator);
187 197
         }
@@ -192,12 +202,14 @@  discard block
 block discarded – undo
192 202
     protected function getPaginator($source, GridSchema $schema): array
193 203
     {
194 204
         $paginator = $schema->getPaginator();
195
-        if (!$paginator instanceof FilterInterface) {
205
+        if (!$paginator instanceof FilterInterface)
206
+        {
196 207
             throw new CompilerException('Paginator can not be null');
197 208
         }
198 209
 
199 210
         $withValue = $paginator->withValue($this->getOption(static::KEY_PAGINATE));
200
-        if ($withValue === null) {
211
+        if ($withValue === null)
212
+        {
201 213
             throw new CompilerException('Paginator can not be null');
202 214
         }
203 215
 
@@ -216,7 +228,8 @@  discard block
 block discarded – undo
216 228
     protected function getOptionArray(string $option): array
217 229
     {
218 230
         $result = $this->getOption($option);
219
-        if (!is_array($result)) {
231
+        if (!is_array($result))
232
+        {
220 233
             return [];
221 234
         }
222 235
 
@@ -231,7 +244,8 @@  discard block
 block discarded – undo
231 244
      */
232 245
     protected function getOption(string $option)
233 246
     {
234
-        if ($this->input->hasValue($option)) {
247
+        if ($this->input->hasValue($option))
248
+        {
235 249
             return $this->input->getValue($option);
236 250
         }
237 251
 
Please login to merge, or discard this patch.
src/DataGrid/src/GridSchema.php 1 patch
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,8 +40,10 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function addWrappedFilters(callable $wrapper, string ...$filters): void
42 42
     {
43
-        foreach ($filters as $filter) {
44
-            if (isset($this->wrappedFilters[$filter])) {
43
+        foreach ($filters as $filter)
44
+        {
45
+            if (isset($this->wrappedFilters[$filter]))
46
+            {
45 47
                 throw new SchemaException("Filter `$filter` is already wrapped");
46 48
             }
47 49
         }
@@ -53,10 +55,13 @@  discard block
 block discarded – undo
53 55
     public function wrapFilters(array $input): array
54 56
     {
55 57
         $output = [];
56
-        foreach ($this->wrappers as $wrapper) {
58
+        foreach ($this->wrappers as $wrapper)
59
+        {
57 60
             $output[] = $wrapper['wrapper'](...$this->fetchFilters($input, $wrapper['filters']));
58
-            foreach ($input as $name => $filter) {
59
-                if (!in_array($name, $wrapper['filters'], true)) {
61
+            foreach ($input as $name => $filter)
62
+            {
63
+                if (!in_array($name, $wrapper['filters'], true))
64
+                {
60 65
                     $output[] = $filter;
61 66
                 }
62 67
             }
@@ -74,7 +79,8 @@  discard block
 block discarded – undo
74 79
      */
75 80
     public function addFilter(string $name, FilterInterface $filter): void
76 81
     {
77
-        if ($this->hasFilter($name)) {
82
+        if ($this->hasFilter($name))
83
+        {
78 84
             throw new SchemaException("Filter `$name` is already defined");
79 85
         }
80 86
 
@@ -99,7 +105,8 @@  discard block
 block discarded – undo
99 105
      */
100 106
     public function getFilter(string $name): FilterInterface
101 107
     {
102
-        if (!$this->hasFilter($name)) {
108
+        if (!$this->hasFilter($name))
109
+        {
103 110
             throw new SchemaException("No such filter `$name`");
104 111
         }
105 112
 
@@ -123,7 +130,8 @@  discard block
 block discarded – undo
123 130
      */
124 131
     public function addSorter(string $name, SorterInterface $sorter): void
125 132
     {
126
-        if ($this->hasSorter($name)) {
133
+        if ($this->hasSorter($name))
134
+        {
127 135
             throw new SchemaException("Sorter `$name` is already defined");
128 136
         }
129 137
 
@@ -148,7 +156,8 @@  discard block
 block discarded – undo
148 156
      */
149 157
     public function getSorter(string $name): SorterInterface
150 158
     {
151
-        if (!$this->hasSorter($name)) {
159
+        if (!$this->hasSorter($name))
160
+        {
152 161
             throw new SchemaException("No such sorter `$name`");
153 162
         }
154 163
 
@@ -186,7 +195,8 @@  discard block
 block discarded – undo
186 195
     private function fetchFilters(array $filters, array $names): array
187 196
     {
188 197
         $output = [];
189
-        foreach ($names as $name) {
198
+        foreach ($names as $name)
199
+        {
190 200
             $output[] = $filters[$name] ?? new NullFilter();
191 201
         }
192 202
 
Please login to merge, or discard this patch.