diff --git a/src/Filter.php b/src/Filter.php index 590cf2c..60be070 100644 --- a/src/Filter.php +++ b/src/Filter.php @@ -279,6 +279,83 @@ public static function alias($string) return $cleaned; } + /** + * String to lower and trim + * + * @param $string + * @return string + */ + public static function low($string) + { + $cleaned = Str::low($string); + $cleaned = Str::trim($cleaned); + + return $cleaned; + } + + /** + * String to upper and trim + * + * @param $string + * @return string + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public static function up($string) + { + $cleaned = Str::up($string); + $cleaned = Str::trim($cleaned); + + return $cleaned; + } + + /** + * Strip spaces + * + * @param $string + * @return string + */ + public static function stripSpace($string) + { + return Str::stripSpace($string); + } + + /** + * @param $string + * @return string + */ + public static function clean($string) + { + return Str::clean($string, true, true); + } + + /** + * @param $string + * @return string + */ + public static function html($string) + { + return Str::htmlEnt($string); + } + + /** + * @param $string + * @return string + */ + public static function xml($string) + { + return Str::escXml($string); + } + + /** + * @param $string + * @return string + */ + public static function esc($string) + { + return Str::esc($string); + } + /** * RAW placeholder * diff --git a/tests/FilterTest.php b/tests/FilterTest.php index f941a02..c2e3c69 100644 --- a/tests/FilterTest.php +++ b/tests/FilterTest.php @@ -260,6 +260,17 @@ public function testApplyRaw() isSame($source, Filter::_($source, ' R A W ')); } + public function testOthers() + { + isSame('low', Filter::_(' LOW ', 'low')); + isSame('UP', Filter::_(' up ', 'up')); + isSame('spaces', Filter::_(' s p a c e s ', 'stripSpace')); + isSame('denis !@#$%^&*()_ 1234567890 qwerty', Filter::_(' Денис !@#$%^&*()_ 1234567890 qwerty ', 'clean')); + isSame(' One & Two <> &mdash; ', Filter::_(' One & Two <> — ', 'html')); + isSame(' One & Two <> &mdash; ', Filter::_(' One & Two <> — ', 'xml')); + isSame(' One & Two <> &mdash; ', Filter::_(' One & Two <> — ', 'esc')); + } + public function testApplyOneRule() { $source = '127.0001 some-WORD ' . "\t";