public function insertProtect(array $matches = [])
    {
        $gen = md5(mt_rand());

        /** @var ISession $s */
        $s = (new SessionInjector)->build();
        $s->csrf = array_merge(is_array($s->csrf) ? $s->csrf : [], [md5($gen)]);

        return $matches[1].'<input type="hidden" name="csrf" value="'.$gen.'" />'.$matches[2].$matches[3];
    }
public function insertProtect(array $matches = [])
    {
        $gen = md5(mt_rand());

        /** @var ISession $s */
        $s = (new SessionInjector)->build();
        $s->csrf = array_merge(is_array($s->csrf) ? $s->csrf : [], [md5($gen)]);

        return $matches[1].'<input type="hidden" name="csrf" value="'.$gen.'" />'.$matches[2].$matches[3];
    }
public function insertProtect ( array $ matches = [ ] ) { $ gen = md5 ( mt_rand ( ) ) ; /** @var ISession $s */ $ s = ( new SessionInjector ) -> build ( ) ; $ s -> csrf = array_merge ( is_array ( $ s -> csrf ) ? $ s -> csrf : [ ] , [ md5 ( $ gen ) ] ) ; return $ matches [ 1 ] . '<input type="hidden" name="csrf" value="' . $ gen . '" />' . $ matches [ 2 ] . $ matches [ 3 ] ; }
Insert CSRF protect into forms

@access public

@param array $matches Form

@return string
@throws Exception
Insert CSRF protect into forms