39 $textWithHtmlSm =
'Before <wrap><in>and</in> another <unclose> <in>word</in></wrap>.';
40 $textWithHtmlLg = str_repeat(
49 if ( !$method || $method ===
'validateEmail' ) {
50 $benches[
'Sanitizer::validateEmail (valid)'] =
static function () {
51 Sanitizer::validateEmail(
'user@example.org' );
53 $benches[
'Sanitizer::validateEmail (invalid)'] =
static function () {
54 Sanitizer::validateEmail(
'username@example! org' );
57 if ( !$method || $method ===
'encodeAttribute' ) {
58 $benches[
'Sanitizer::encodeAttribute (simple)'] =
static function () {
59 Sanitizer::encodeAttribute(
'simple' );
61 $benches[
'Sanitizer::encodeAttribute (special)'] =
static function () {
62 Sanitizer::encodeAttribute(
":'\"\n https://example" );
65 if ( !$method || $method ===
'safeEncodeAttribute' ) {
66 $benches[
'Sanitizer::safeEncodeAttribute (simple)'] =
static function () {
67 Sanitizer::safeEncodeAttribute(
'simple' );
69 $benches[
'Sanitizer::safeEncodeAttribute (special)'] =
static function () {
70 Sanitizer::safeEncodeAttribute(
":'\"\n https://example" );
73 if ( !$method || $method ===
'removeHTMLtags' ) {
74 $sm = strlen( $textWithHtmlSm );
75 $lg = round( strlen( $textWithHtmlLg ) / 1000 ) .
'K';
76 $benches[
"Sanitizer::removeHTMLtags (input: $sm)"] =
static function () use ( $textWithHtmlSm ) {
77 Sanitizer::removeHTMLtags( $textWithHtmlSm );
79 $benches[
"Sanitizer::removeHTMLtags (input: $lg)"] =
static function () use ( $textWithHtmlLg ) {
80 Sanitizer::removeHTMLtags( $textWithHtmlLg );
83 if ( !$method || $method ===
'stripAllTags' ) {
84 $sm = strlen( $textWithHtmlSm );
85 $lg = round( strlen( $textWithHtmlLg ) / 1000 ) .
'K';
86 $benches[
"Sanitizer::stripAllTags (input: $sm)"] =
static function () use ( $textWithHtmlSm ) {
87 Sanitizer::stripAllTags( $textWithHtmlSm );
89 $benches[
"Sanitizer::stripAllTags (input: $lg)"] =
static function () use ( $textWithHtmlLg ) {
90 Sanitizer::stripAllTags( $textWithHtmlLg );
94 $this->
bench( $benches );