src/CsrfMiddleware.php
private function injectFormHiddenFieldToResponse(string $body, string $tokenValue): string
    {
        $regex = '/(<form\b[^>]*>)(.*?)(<\/form>)/is';
        $htmlHiddenField = sprintf('$1<input type="hidden" name="%s" value="%s">$2$3', $this->name, $tokenValue);
        $body = preg_replace($regex, $htmlHiddenField, $body);

        return (string)$body;
    }
private function injectFormHiddenFieldToResponse(string $body, string $tokenValue): string
    {
        $regex = '/(<form\b[^>]*>)(.*?)(<\/form>)/is';
        $htmlHiddenField = sprintf('$1<input type="hidden" name="%s" value="%s">$2$3', $this->name, $tokenValue);
        $body = preg_replace($regex, $htmlHiddenField, $body);

        return (string)$body;
    }
private function injectFormHiddenFieldToResponse ( string $ body , string $ tokenValue ) : string { $ regex = '/(<form\b[^>]*>)(.*?)(<\/form>)/is' ; $ htmlHiddenField = sprintf ( '$1<input type="hidden" name="%s" value="%s">$2$3' , $ this -> name , $ tokenValue ) ; $ body = preg_replace ( $ regex , $ htmlHiddenField , $ body ) ; return ( string ) $ body ; }
Inject hidden field.

@param string $body body
@param string $tokenValue token

@return string html
Inject hidden field .