Pop\Filter

The popphp/pop-filter component provides some basic filtering for common situations.

Installation

Install it directly into your project:

composer require popphp/pop-filter

Or, include it in your composer.json file:

{
    "require": {
        "popphp/pop-filter": "2.1.*",
    }
}

Basic Use

URL Slug

echo Pop\Filter\Slug::filter("Hello World What's Up?");
hello-world-whats-up

You can pass it a separator as well:

echo Pop\Filter\Slug::filter("About Us : Company : President", ' : ');
about-us/company/president

Random String

The Pop\Filter\Random has 4 constants you can combine to tailor your results:

  • Pop\Filter\Random::ALPHA
  • Pop\Filter\Random::ALPHANUM
  • Pop\Filter\Random::LOWERCASE
  • Pop\Filter\Random::UPPERCASE
echo Pop\Filter\Random::create(8, Random::ALPHANUM|Random::LOWERCASE);
sjd873k3

Convert Case

echo Pop\Filter\ConvertCase::underscoreToCamelcase('myapp_table_users');
MyTableUsers
// The separator defaults to DIRECTORY_SEPARATOR, but you can pass
// a custom value in as well
echo Pop\Filter\ConvertCase::camelCaseToSeparator('MyTableUsers');
My/Table/Users