private function inject(ResponseInterface $response, $code, $tag = 'body')
    {
        $html = (string) $response->getBody();
        $pos = strripos($html, "</{$tag}>");

        if ($pos === false) {
            $response->getBody()->write($code);

            return $response;
        }

        $body = self::createStream();
        $body->write(substr($html, 0, $pos).$code.substr($html, $pos));

        return $response->withBody($body);
    }
private function inject(ResponseInterface $response, $code, $tag = 'body')
    {
        $html = (string) $response->getBody();
        $pos = strripos($html, "</{$tag}>");

        if ($pos === false) {
            $response->getBody()->write($code);

            return $response;
        }

        $body = self::createStream();
        $body->write(substr($html, 0, $pos).$code.substr($html, $pos));

        return $response->withBody($body);
    }
private function inject ( ResponseInterface $ response , $ code , $ tag = 'body' ) { $ html = ( string ) $ response -> getBody ( ) ; $ pos = strripos ( $ html , "</{$tag}>" ) ; if ( $ pos === false ) { $ response -> getBody ( ) -> write ( $ code ) ; return $ response ; } $ body = self :: createStream ( ) ; $ body -> write ( substr ( $ html , 0 , $ pos ) . $ code . substr ( $ html , $ pos ) ) ; return $ response -> withBody ( $ body ) ; }
Inject some code just before any tag.

@param ResponseInterface $response
@param string            $code
@param string            $tag

@return ResponseInterface
Inject some code just before any tag .