Download the PHP package bayfrontmedia/php-string-helpers without Composer
On this page you can find all versions of the php package bayfrontmedia/php-string-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bayfrontmedia/php-string-helpers
More information about bayfrontmedia/php-string-helpers
Files in bayfrontmedia/php-string-helpers
Package php-string-helpers
Short Description Helper class to provide useful string functions.
License MIT
Homepage https://github.com/bayfrontmedia/php-string-helpers
Informations about the package php-string-helpers
PHP string helpers
PHP helper class to provide useful string functions.
- License
- Author
- Requirements
- Installation
- Usage
License
This project is open source and available under the MIT License.
Author
Requirements
- PHP
^8.0(Tested up to8.4)
Installation
Usage
- startWith
- endWith
- lowercase
- uppercase
- titleCase
- camelCase
- kebabCase
- snakeCase
- random
- uid
- uuid4
- uuid7
- isValidUuid
- binToUuid
- uuidToBin
- hasComplexity
Depreciated:
- has
- hasSpace
- startsWith
- endsWith
- uuid
startWith
Description:
Returns string, ensuring that it starts with a given string.
Parameters:
$string(string)$start_with(string)
Returns:
- (string)
Example:
endWith
Description:
Returns string, ensuring that it ends with a given string.
Parameters:
$string(string)$end_with(string)
Returns:
- (string)
Example:
lowercase
Description:
Converts string to lowercase using a specified character encoding.
See: https://www.php.net/manual/en/mbstring.supported-encodings.php
Parameters:
$string(string)$encoding = 'UTF-8'(string)
Returns:
- (string)
Example:
uppercase
Description:
Converts string to uppercase using a specified character encoding.
See: https://www.php.net/manual/en/mbstring.supported-encodings.php
Parameters:
$string(string)$encoding = 'UTF-8'(string)
Returns:
- (string)
Example:
titleCase
Description:
Converts string to title case using a specified character encoding.
See: https://www.php.net/manual/en/mbstring.supported-encodings.php
Parameters:
$string(string)$encoding = 'UTF-8'(string)
Returns:
- (string)
Example:
camelCase
Description:
Converts string to camel case, removing any non-alpha and non-numeric characters.
Parameters:
$string(string)
Returns:
- (string)
Example:
kebabCase
Description:
Converts string to kebab case (URL-friendly slug), replacing any non-alpha and non-numeric characters with a hyphen.
Parameters:
$string(string)$lowercase = false(bool): Convert string to lowercase
Returns:
- (string)
Example:
snakeCase
Description:
Converts string to snake case, replacing any non-alpha and non-numeric characters with an underscore.
Parameters:
$string(string)$lowercase = false(bool): Convert string to lowercase
Returns:
- (string)
Example:
random
Description:
Return a random string of specified length and type.
Note: Returned string is not cryptographically secure.
Parameters:
$length = 8(int)$type = self::RANDOM_TYPE_ALL(string): AnyRANDOM_TYPE_*constant)
Valid $type constants include:
RANDOM_TYPE_NONZERORANDOM_TYPE_NUMERICRANDOM_TYPE_ALPHA: Alphabetic, upper and lowercaseRANDOM_TYPE_ALPHA_LOWERRANDOM_TYPE_ALPHA_UPPERRANDOM_TYPE_ALPHANUMERIC: Alphanumeric, upper and lowercaseRANDOM_TYPE_ALPHANUMERIC_LOWERRANDOM_TYPE_ALPHANUMERIC_UPPERRANDOM_TYPE_ALL: Alphanumeric and special characters
Backticks and quotation marks are excluded from special characters for safely inserting into a database.
Returns:
- (string)
Example:
uid
Description:
Return a cryptographically secure unique identifier (UID) comprised of lowercase letters and numbers.
Parameters:
$length = 8(int)
Returns:
- (string)
Example:
uuid4
Description:
Return a UUID v4 string.
Parameters:
- (None)
Returns:
- (string)
Example:
uuid7
Description:
Return a lexicographically sortable UUID v7 string.
Parameters:
- (None)
Returns:
- (string)
Example:
isValidUuid
Description:
Is string a valid UUID?
Parameters:
$uuid(string)
Returns:
- (boolean)
Example:
binToUuid
Description:
Convert 16 byte binary string to UUID.
Parameters:
$binary(string)
Returns:
- (string)
Example:
uuidToBin
Description:
Convert UUID to 16 byte binary string.
Parameters:
$uuid(string)
Returns:
- (string)
Example:
hasComplexity
Description:
Verify input string has a specified complexity.
Parameters:
$string(string)$min_length(int)$max_length(int):0for no max$lowercase(int): Minimum number of lowercase characters$uppercase(int): Minimum number of uppercase characters$digits(int): Minimum number of digits$special_chars(int): Minimum number of non-alphabetic and non-numeric characters
Returns:
- (bool)
Example:
has
Description:
Checks if string contains a case-sensitive needle.
This method has been depreciated in favor of PHP native function str_contains.
Parameters:
$string(string)$needle(string)
Returns:
- (bool)
Example:
hasSpace
Description:
Checks if string contains any whitespace.
This method has been depreciated in favor of PHP native function str_contains.
Parameters:
$string(string)
Returns:
- (bool)
Example:
startsWith
Description:
Checks if a string starts with a given case-sensitive string.
This method has been depreciated in favor of PHP native function str_starts_with.
Parameters:
$string(string)$starts_with(string)
Returns:
- (bool)
Example:
endsWith
Description:
Checks if a string ends with a given case-sensitive string.
This method has been depreciated in favor of PHP native function str_ends_with.
Parameters:
$string(string)$ends_with(string)
Returns:
- (bool)
Example:
uuid
Description:
Return a UUID v4 string.
This method has been depreciated in favor of Str::uuid7.
Parameters:
- (None)
Returns:
- (string)
Example:
All versions of php-string-helpers with dependencies
ext-mbstring Version *
ext-iconv Version *