Skip to content

Commit

Permalink
new filters
Browse files Browse the repository at this point in the history
  • Loading branch information
SmetDenis committed Feb 20, 2016
1 parent b9fbf62 commit 5c57489
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
77 changes: 77 additions & 0 deletions src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
11 changes: 11 additions & 0 deletions tests/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 &amp; Two &lt;&gt; &amp;mdash; ', Filter::_(' One & Two <> &mdash; ', 'html'));
isSame(' One &amp; Two &lt;&gt; &amp;mdash; ', Filter::_(' One & Two <> &mdash; ', 'xml'));
isSame(' One &amp; Two &lt;&gt; &amp;mdash; ', Filter::_(' One & Two <> &mdash; ', 'esc'));
}

public function testApplyOneRule()
{
$source = '127.0001 <img> some-<b>WORD</b> ' . "\t";
Expand Down

0 comments on commit 5c57489

Please sign in to comment.