Skip to content

Commit a54095b

Browse files
committed
refactor: use private methods
1 parent cdb3bf1 commit a54095b

File tree

1 file changed

+11
-42
lines changed

1 file changed

+11
-42
lines changed

system/Filters/Filters.php

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -302,55 +302,24 @@ public function runRequired(string $position = 'before')
302302
}
303303
}
304304

305-
foreach ($filtersClass[$position] as $className) {
306-
$class = new $className();
307-
308-
if (! $class instanceof FilterInterface) {
309-
throw FilterException::forIncorrectInterface(get_class($class));
310-
}
311-
312-
if ($position === 'before') {
313-
$result = $class->before(
314-
$this->request,
315-
$this->argumentsClass[$className] ?? null
316-
);
317-
318-
if ($result instanceof RequestInterface) {
319-
$this->request = $result;
320-
321-
continue;
322-
}
323-
324-
// If the response object was sent back,
325-
// then send it and quit.
326-
if ($result instanceof ResponseInterface) {
327-
// short circuit - bypass any other filters
328-
return $result;
329-
}
330-
// Ignore an empty result
331-
if (empty($result)) {
332-
continue;
333-
}
305+
if ($position === 'before') {
306+
$result = $this->runBefore($filtersClass);
334307

308+
// If the response object was sent back,
309+
// then send it and quit.
310+
if ($result instanceof ResponseInterface) {
311+
// short circuit - bypass any other filters
335312
return $result;
336313
}
337314

338-
if ($position === 'after') {
339-
$result = $class->after(
340-
$this->request,
341-
$this->response,
342-
$this->argumentsClass[$className] ?? null
343-
);
344-
345-
if ($result instanceof ResponseInterface) {
346-
$this->response = $result;
315+
return $result;
316+
}
347317

348-
continue;
349-
}
350-
}
318+
if ($position === 'after') {
319+
$result = $this->runAfter($filtersClass);
351320
}
352321

353-
return $position === 'before' ? $this->request : $this->response;
322+
return $result;
354323
}
355324

356325
/**

0 commit comments

Comments
 (0)