Skip to content

Instantly share code, notes, and snippets.

@reinink
Created December 31, 2016 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reinink/d5f4aa69d2b1981eb911a00b865e0160 to your computer and use it in GitHub Desktop.
Save reinink/d5f4aa69d2b1981eb911a00b865e0160 to your computer and use it in GitHub Desktop.
<?php
namespace ChurchSocial\Middleware;
use Closure;
class TrimMiddleware
{
public function handle($request, Closure $next)
{
$request->replace(
$this->trimArray($request->all())
);
return $next($request);
}
protected function trimArray($input)
{
if (is_string($input)) {
return trim($input);
}
if (is_array($input)) {
return array_map([$this, 'trimArray'], $input);
}
return $input;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment