@@ -108,7 +108,7 @@ discard block |
||
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 | throw new GridViewException('GridView expects the source to be iterable after all.'); |
113 | 113 | } |
114 | 114 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | protected function getFilters($source, GridSchema $schema): array |
127 | 127 | { |
128 | 128 | $filters = []; |
129 | - foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) { |
|
130 | - if ($schema->hasFilter($name)) { |
|
129 | + foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value){ |
|
130 | + if ($schema->hasFilter($name)){ |
|
131 | 131 | $filter = $schema->getFilter($name)->withValue($value); |
132 | 132 | |
133 | - if ($filter !== null) { |
|
133 | + if ($filter !== null){ |
|
134 | 134 | $source = $this->compiler->compile($source, $filter); |
135 | 135 | $filters[$name] = $filter->getValue(); |
136 | 136 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | protected function applyCounter(GridInterface $view, $source, GridSchema $schema): array |
144 | 144 | { |
145 | - if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) { |
|
145 | + if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)){ |
|
146 | 146 | $view = $view->withOption(GridInterface::COUNT, ($this->count)($source)); |
147 | 147 | } |
148 | 148 | |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | protected function getSorters($source, GridSchema $schema): array |
161 | 161 | { |
162 | 162 | $sorters = []; |
163 | - foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) { |
|
164 | - if ($schema->hasSorter($name)) { |
|
163 | + foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value){ |
|
164 | + if ($schema->hasSorter($name)){ |
|
165 | 165 | $sorter = $schema->getSorter($name)->withDirection($value); |
166 | 166 | |
167 | - if ($sorter !== null) { |
|
167 | + if ($sorter !== null){ |
|
168 | 168 | $source = $this->compiler->compile($source, $sorter); |
169 | 169 | $sorters[$name] = $sorter->getValue(); |
170 | 170 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | protected function applyPaginator(GridInterface $view, $source, GridSchema $schema): array |
178 | 178 | { |
179 | - if ($schema->getPaginator() !== null) { |
|
179 | + if ($schema->getPaginator() !== null){ |
|
180 | 180 | ['source' => $source, 'paginator' => $paginator] = $this->getPaginator($source, $schema); |
181 | 181 | $view = $view->withOption(GridInterface::PAGINATOR, $paginator); |
182 | 182 | } |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | protected function getPaginator($source, GridSchema $schema): array |
188 | 188 | { |
189 | 189 | $paginator = $schema->getPaginator(); |
190 | - if (!$paginator instanceof FilterInterface) { |
|
190 | + if (!$paginator instanceof FilterInterface){ |
|
191 | 191 | throw new CompilerException('Paginator can not be null'); |
192 | 192 | } |
193 | 193 | |
194 | 194 | $withValue = $paginator->withValue($this->getOption(static::KEY_PAGINATE)); |
195 | - if ($withValue === null) { |
|
195 | + if ($withValue === null){ |
|
196 | 196 | throw new CompilerException('Paginator can not be null'); |
197 | 197 | } |
198 | 198 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | protected function getOptionArray(string $option): array |
212 | 212 | { |
213 | 213 | $result = $this->getOption($option); |
214 | - if (!is_array($result)) { |
|
214 | + if (!is_array($result)){ |
|
215 | 215 | return []; |
216 | 216 | } |
217 | 217 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function getOption(string $option) |
228 | 228 | { |
229 | - if ($this->input->hasValue($option)) { |
|
229 | + if ($this->input->hasValue($option)){ |
|
230 | 230 | return $this->input->getValue($option); |
231 | 231 | } |
232 | 232 |
@@ -108,7 +108,8 @@ discard block |
||
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 | |
@@ -126,11 +127,14 @@ discard block |
||
126 | 127 | protected function getFilters($source, GridSchema $schema): array |
127 | 128 | { |
128 | 129 | $filters = []; |
129 | - foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) { |
|
130 | - if ($schema->hasFilter($name)) { |
|
130 | + foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) |
|
131 | + { |
|
132 | + if ($schema->hasFilter($name)) |
|
133 | + { |
|
131 | 134 | $filter = $schema->getFilter($name)->withValue($value); |
132 | 135 | |
133 | - if ($filter !== null) { |
|
136 | + if ($filter !== null) |
|
137 | + { |
|
134 | 138 | $source = $this->compiler->compile($source, $filter); |
135 | 139 | $filters[$name] = $filter->getValue(); |
136 | 140 | } |
@@ -142,7 +146,8 @@ discard block |
||
142 | 146 | |
143 | 147 | protected function applyCounter(GridInterface $view, $source, GridSchema $schema): array |
144 | 148 | { |
145 | - if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) { |
|
149 | + if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) |
|
150 | + { |
|
146 | 151 | $view = $view->withOption(GridInterface::COUNT, ($this->count)($source)); |
147 | 152 | } |
148 | 153 | |
@@ -160,11 +165,14 @@ discard block |
||
160 | 165 | protected function getSorters($source, GridSchema $schema): array |
161 | 166 | { |
162 | 167 | $sorters = []; |
163 | - foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) { |
|
164 | - if ($schema->hasSorter($name)) { |
|
168 | + foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) |
|
169 | + { |
|
170 | + if ($schema->hasSorter($name)) |
|
171 | + { |
|
165 | 172 | $sorter = $schema->getSorter($name)->withDirection($value); |
166 | 173 | |
167 | - if ($sorter !== null) { |
|
174 | + if ($sorter !== null) |
|
175 | + { |
|
168 | 176 | $source = $this->compiler->compile($source, $sorter); |
169 | 177 | $sorters[$name] = $sorter->getValue(); |
170 | 178 | } |
@@ -176,7 +184,8 @@ discard block |
||
176 | 184 | |
177 | 185 | protected function applyPaginator(GridInterface $view, $source, GridSchema $schema): array |
178 | 186 | { |
179 | - if ($schema->getPaginator() !== null) { |
|
187 | + if ($schema->getPaginator() !== null) |
|
188 | + { |
|
180 | 189 | ['source' => $source, 'paginator' => $paginator] = $this->getPaginator($source, $schema); |
181 | 190 | $view = $view->withOption(GridInterface::PAGINATOR, $paginator); |
182 | 191 | } |
@@ -187,12 +196,14 @@ discard block |
||
187 | 196 | protected function getPaginator($source, GridSchema $schema): array |
188 | 197 | { |
189 | 198 | $paginator = $schema->getPaginator(); |
190 | - if (!$paginator instanceof FilterInterface) { |
|
199 | + if (!$paginator instanceof FilterInterface) |
|
200 | + { |
|
191 | 201 | throw new CompilerException('Paginator can not be null'); |
192 | 202 | } |
193 | 203 | |
194 | 204 | $withValue = $paginator->withValue($this->getOption(static::KEY_PAGINATE)); |
195 | - if ($withValue === null) { |
|
205 | + if ($withValue === null) |
|
206 | + { |
|
196 | 207 | throw new CompilerException('Paginator can not be null'); |
197 | 208 | } |
198 | 209 | |
@@ -211,7 +222,8 @@ discard block |
||
211 | 222 | protected function getOptionArray(string $option): array |
212 | 223 | { |
213 | 224 | $result = $this->getOption($option); |
214 | - if (!is_array($result)) { |
|
225 | + if (!is_array($result)) |
|
226 | + { |
|
215 | 227 | return []; |
216 | 228 | } |
217 | 229 | |
@@ -226,7 +238,8 @@ discard block |
||
226 | 238 | */ |
227 | 239 | protected function getOption(string $option) |
228 | 240 | { |
229 | - if ($this->input->hasValue($option)) { |
|
241 | + if ($this->input->hasValue($option)) |
|
242 | + { |
|
230 | 243 | return $this->input->getValue($option); |
231 | 244 | } |
232 | 245 |