Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php
Строк: 47
<?php

namespace IlluminateFoundationHttpMiddleware;

use 
Closure;

class 
TrimStrings extends TransformsRequest
{
    
/**
     * All of the registered skip callbacks.
     *
     * @var array
     */
    
protected static $skipCallbacks = [];

    
/**
     * The attributes that should not be trimmed.
     *
     * @var array<int, string>
     */
    
protected $except = [
        
//
    
];

    
/**
     * Handle an incoming request.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Closure  $next
     * @return mixed
     */
    
public function handle($requestClosure $next)
    {
        foreach (static::
$skipCallbacks as $callback) {
            if (
$callback($request)) {
                return 
$next($request);
            }
        }

        return 
parent::handle($request$next);
    }

    
/**
     * Transform the given value.
     *
     * @param  string  $key
     * @param  mixed  $value
     * @return mixed
     */
    
protected function transform($key$value)
    {
        if (
in_array($key$this->excepttrue) || ! is_string($value)) {
            return 
$value;
        }

        return 
preg_replace('~^[sx{FEFF}x{200B}]+|[sx{FEFF}x{200B}]+$~u'''$value) ?? trim($value);
    }

    
/**
     * Register a callback that instructs the middleware to be skipped.
     *
     * @param  Closure  $callback
     * @return void
     */
    
public static function skipWhen(Closure $callback)
    {
        static::
$skipCallbacks[] = $callback;
    }

    
/**
     * Flush the middleware's global state.
     *
     * @return void
     */
    
public static function flushState()
    {
        static::
$skipCallbacks = [];
    }
}
Онлайн: 1
Реклама