typedphp / string-functions
0.1.0
2014-12-15 18:35 UTC
Requires
- php: >=5.4.0
- typedphp/type-functions: *
Requires (Dev)
- phpunit/phpunit: 4.*
README
Example
use TypedPHP\Functions\StringFunctions; StringFunctions\endsWith("a long string", "string"); // true StringFunctions\replace("a long string", "long", "enormous"); // "a enormous string"
Functions:
startsWith(string $haystack, string $needle) → bool
endsWith(string $haystack, string $needle) → bool
indexOf(string $haystack, string $needle, int $offset = 0) → int
length(string $string) → int
matches(string $haystack, string $needle) → bool
replace(string $haystack, string|array $needle, string|array $replacement) → string
slice(string $string, int $offset = 0, int $limit = 0) → string
split(string $haystack, string|null $needle = null, int $limit = 0) → array
trim(string $haystack, string $needle) → string
trimLeft(string $haystack, string $needle) → string
trimRight(string $haystack, string $needle) → string
Caveats:
- Every
$needle
can be a normal string or a regular expression string.
Installation
❯ composer require "typedphp/string-functions:*"
Testing
❯ composer create-project "typedphp/string-functions:*" . ❯ vendor/bin/phpunit