Created
December 31, 2016 00:19
-
-
Save reinink/d5f4aa69d2b1981eb911a00b865e0160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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