rkr / strings
0.0.1
2014-03-18 08:49 UTC
Requires
- php: >= 5.3
Requires (Dev)
- phpunit/phpunit: ~3.7
This package is auto-updated.
Last update: 2024-12-22 22:20:45 UTC
README
Design-goals
- Consistent interface.
- All names are lowerCamelCase.
- Required parameters are always at the beginning.
- Homogeneous parameters follow conventions: $haystack is always before $needle.
- Proper null handling.
Functions
- at
\rkr\str\at(string|null string, int|null position): string|null
Get the character at the specified position in a string. - bagDistance
\rkr\str\bagDistance(string|null string1, string|null string2): int|null
Calculate the bag distance between two strings. - capitalize
\rkr\str\capitalize(string|null string): string|null
Capitalize the first character of the string. - capitalizeWords
\rkr\str\capitalizeWords(string|null string): string|null
Capitalize the first letter of each word in a string. - characters
\rkr\str\characters(string|null string): array|null
Get the Unicode characters of a string. - chunk
\rkr\str\chunk(string|null string, int length): array|null
Splits a string into chunks of the given length. - contains
\rkr\str\contains(string|null haystack, string|null needle): bool
Check if a string contains another string. - duplicate
\rkr\str\duplicate(string|null string, int times): string|null
Duplicate a string a given number of times. - endsWith
\rkr\str\endsWith(string|null haystack, string|null needle): bool
Checks if the haystack ends with the needle. - equals
\rkr\str\equals(string|null string1, string|null string2): bool
Asserts that a string is equal to another string. - first
\rkr\str\first(string|null string): string|null
Get the first character of a string. - indexOf
\rkr\str\indexOf(string|null haystack, string|null needle, int offset): int|null
Finds the position of the first occurrence of a substring in a string. - jaroDistance
\rkr\str\jaroDistance(string|null string1, string|null string2): float|null
Calculate the Jaro distance between two strings. - last
\rkr\str\last(string|null string): string|null
Get the last character of a string. - lastIndexOf
\rkr\str\lastIndexOf(string|null haystack, string|null needle, int offset): int|null
Find the last occurrence of a string in another string. - length
\rkr\str\length(string|null string): int|null
Get the length of the string. - lower
\rkr\str\lower(string|null string): string|null
Converts a string to lowercase. - matches
\rkr\str\matches(string|null string, string|null pattern): bool
Check if a string matches a regular expression pattern. - myersDifference
\rkr\str\myersDifference(string|null string1, string|null string2): int|null
Calculate the Myers difference between two strings. - normalize
\rkr\str\normalize(string|null string, string form): string|null
Normalize a string using a specified normalization form. - padLeading
\rkr\str\padLeading(string|null string, int length, string|null substring): string|null
Pads the given string on the left side to the specified length with the specified character. - padTrailing
\rkr\str\padTrailing(string|null string, positive-int length, string char): string|null
Pads the given string to the specified length with the given character. - replace
\rkr\str\replace(string|null haystack, string|null needle, string|null replacement): string|null
Replace all occurrences of the needle in the haystack with the replacement. - replaceFirst
\rkr\str\replaceFirst(string|null haystack, string|null needle, string|null replacement): string|null
Replace the first occurrence of a needle in the haystack with a replacement. - replaceLast
\rkr\str\replaceLast(string|null haystack, string|null needle, string|null replacement): string|null
Replaces all occurrences of a string in another string. - replacePrefix
\rkr\str\replacePrefix(string|null string, string|null prefix, string|null replacement): string|null
Replace the prefix of a string with another string. - replaceSuffix
\rkr\str\replaceSuffix(string|null string, string|null suffix, string|null replacement): string|null
Replaces the suffix of a string. - reverse
\rkr\str\reverse(string|null string): string|null
Reverse a given string. - shift
\rkr\str\shift(string|null string, positive-int length): null|array{: string, : string}
Shifts a string by a given length. - startsWith
\rkr\str\startsWith(string|null haystack, string|null needle): bool
Checks if the haystack starts with the needle. - substr
\rkr\str\substr(string|null string, int start, int|null length): string|null
Get a substring of a string. - trim
\rkr\str\trim(string|null string, string|null chars null): string|null
Trims the given string by removing the specified characters from the beginning and the end. - trimLeft
\rkr\str\trimLeft(string|null string, string|null chars null): string|null
Trims the specified characters from the beginning of the string. - trimRight
\rkr\str\trimRight(string|null string, string|null chars null): string|null
Trims the specified characters from the end of the string. - upper
\rkr\str\upper(string|null string): string|null
Convert a string to uppercase.