Download the PHP package traderinteractive/filter-strings without Composer
On this page you can find all versions of the php package traderinteractive/filter-strings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package filter-strings
filter-strings-php
A filtering implementation for verifying the contents of strings and some common formats of strings.
Requirements
Requires PHP 7.0 or newer and uses composer to install further PHP dependencies. See the composer specification for more details.
Installation
filter-strings-php can be installed for use in your project using composer.
The recommended way of using this library in your project is to add a composer.json
file to your project. The following contents would add filter-strings-php as a dependency:
Functionality
Strings::filter
This filter verifies that the argument is a string. The second parameter can be set to true
to allow
null values through without an error (they will stay null and not get converted to false). The last parameters specify the length bounds of the
string. The default bounds are 1+, so an empty string fails by default.
The following checks that $value
is a non-empty string.
Strings::concat
This filter concatenates the given $value, $prefix and $suffix and returns the resulting string.
Strings::translate
This filter will accept a string value and return its translated value found in the given $valueMap.
Strings::explode
This filter is essentially a wrapper around the built-in explode
method
with the value first in order to work with the Filterer
. It also defaults to using ,
as a delimiter. For example:
Strings::compress
This filter trims and remove superfluous whitespace from a given string.
This filter can also replace vertical whitespace such as newlines with single spaces.
Strings::redact
This filter will remove specified words from a string or, optionally, replace each letter of the words with a replacement character.
The second argument specifies the words that should be replaced and can either be an array of strings or a callable that returns an array of strings.
The third argument specifies the replacement character. If empty, the words will be removed entirely. If a string with more than one character is provided, only the first character will be used.
Strings::stripTags
This filter will strip HTML, XML, and PHP tags from a string. This filter also accepts null values, which will be returned as null.
The second, optional argument specifies a replacement string for the removed HTML and XML tags. PHP tags will be stripped without a replacement.
Url::filter
This filter verifies that the argument is a URL string according to
RFC2396. The second parameter can be set to true
to allow
null values through without an error (they will stay null and not get converted to false).
The following checks that $value
is a URL.
Email::filter
This filter verifies that the argument is an email.
The following checks that $value
is an email.
Json::validate
This filter verifies that the value is in a valid JSON format.
The second parameter can be set to true
to allow null values through without an error.
The third parameter determines the maximum recursion depth that is allowed.
The following checks that $value
is a valid JSON string.
Json::parse
This filter parses a valid JSON string into an array, int, double, or bool. Invalid JSON will throw an error.
The second parameter can be set to true
to allow null values through without an error.
The third parameter determines the maximum recursion depth that is allowed.
The following checks that $value
is a valid JSON string and parses it into an array.
UuidFilter::filter
This filter verifies a given string is a valid universally unique identifier.
The second parameter can be set to true
to allow null values through without an error.
The third parameter can be set to true
to allow Nil UUIDs values through without an error.
The fourth parameter determines which UUID version the value will be validated against. By default, the filter will succeed if the values matches version 1, 2, 3, 4, 5, 6, or 7
XmlFilter::filter
This filter ensures the given string is valid XML.
XmlFilter::extract
This filter accepts an XML string and an xpath. It will return the single element found at the xpath.
XmlFilter::validate
This filter accepts an XML string and a filepath to an XSD. It ensures the given XML is valid using the given XSD and returns the original XML.
Contact
Developers may be contacted at:
Project Build
With a checkout of the code get Composer in your PATH and run:
For more information on our build process, read through out our Contribution Guidelines.