Download the PHP package jasonlam604/stringizer without Composer
On this page you can find all versions of the php package jasonlam604/stringizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jasonlam604/stringizer
More information about jasonlam604/stringizer
Files in jasonlam604/stringizer
Package stringizer
Short Description Stringizer is a PHP string manipulation library with support for method chaining and multibyte handling
License MIT
Homepage http://jasonlam604.github.io/Stringizer/
Informations about the package stringizer
Stringizer
Stringizer is a PHP string manipulation library with support for method chaining and multibyte handling
- Overview
- Key Highlights
- Version
- Installation
- Tests
- Submitting Bugs / Issues
- Contributing
- Credits
- License
Basic Functions
- String Setter
- String Getter
- String Orginal Value Getter
- PHP built in toString
- Encoding Setter
- Encoding Getter
String Functions
- Base64Encode
- Base64Decode
- Between
- Camelize
- CamelToSnake
- CharAt
- Chars
- ChompLeft - deprecated
- ChompRight - deprecated
- ChopLeft
- ChopRight
- CollapseWhitespace
- Concat
- Contains & Contains Case-Insensitive
- Contains Count & Count Case-Insensitive
- Dasherize
- Delete
- EndsWith
- EnsureLeft
- EnsureRight
- First
- HasLowerCase
- HasUpper
- HashCode
- IndexOf & IndexOf Case-Insensitive
- IsAscii
- IsAlpha
- IsAlphaNumeric
- IsAlphaNumeric with Space
- IsAlphaNumeric with Space and Dash
- IsBase64
- IsBlank
- IsDate
- IsDecimal
- IsEmail
- IsEmpty
- IsHash
- IsHexColor
- IsHexDecimal
- IsIsbn10
- IsIsbn10
- IsIpv4
- IsIpv6
- IsJson
- IsNumber
- IsMultiByte
- IsLatitude
- IsLongitude
- IsRgbColor
- IsSemver
- IsUrl
- Join
- Last
- LastIndexOf & LastIndexOf Case-Insensitive
- Length
- LineCount
- Lowercase
- Lowercase First
- Pad Both
- Pad Left
- Pad Right
- RandomAlpha
- RandomNumeric
- RandomAlphaNumeric
- Replace Accents
- Remove Non Ascii
- Remove Whitespace
- Repeat
- Replace & Replace Case-Insensitive
- Reverse
- SentenceCount
- Split
- StartsWith
- Strip Punctuation
- Strip Tags
- Sub String
- SwapCase
- ToBoolean
- Trim
- Trim Left
- Trim Right
- Truncate
- Truncate Match & Truncate Match Case-Insensitive
- Uppercase
- Uppercase Words
- Width
- WordCount
Overview
Stringizer is a string library made up of existing PHP multibyte-string functions and a variety of string manipulation solutions found on Stackoverflow.com. The intent is to save you time looking up string maninpulation solutions yourself and provide the convience of method chaining. Awarded the Innovation Award in June 2016 from PHPClasses.org.
PSR Compliance and Code Quality:
- PSR-0: Autoloading Standard
- PSR-1: Basic Coding Standard
- PSR-2: Coding Style
- PSR-4: Autoloader
- Semver Versioning
- 100% Unit Test Coverage, results by Coveralls.io
- Platinum Code Quality Analysis by SensioLabsInsight
- Continuous Integration and regression unit testing using Travis CI
Key Highlights
- Built in Multibyte support, where applicable and possible
- Chaining of functions
- In some case removing the hassle of you trying to figure out the right regex solution
Version
Installation
It's recommended that you use Composer to install Stringizer.
Manual install with composer
Using the composer.json file
This will install Stringizer and all required dependencies. Stringizer requires PHP 5.6.0 or newer.
Usage
Sample usage:
Tests
To execute the test suite, you'll need phpunit.
Submit Issues
Feel free to open any Issues, Bugs or suggestions!
Contributing
Accepting Pull-Requests!
Credits
License
The Stringizer is licensed under the MIT license. See License File for more information.
String Functions
base64Decode
Bae64 decode string
base64Encode
Base64 Encode String
between
Extracts a string between left and right strings.
camelize
Removes any underscores or dashes and converts a string into camel case.
camelToSnake
Converts Camel case to Snake Case.
charAt
Obtain character at specific position in a string where the first position is consider 0.
chars
Return the given string as an array where each index contains a character.
chompLeft
Deprecated - Removes prefix from start of string.
chompRight
Deprecated - Removes suffix from start of string.
chopLeft
Removes prefix from start of string.
chopRight
Removes suffix from start of string.
collapseWhitespace
Remove extra whitespace, leave only one whitespace between characters where there is more then one whitespace value.
concat
Combine string values.
Combine at end of the string.
Combine at the beginning of the string by passing in the boolean value true in the optional second parameter.
contains
Search for string within another string, return true if found else return false
containsCount
Count the number of string occurrences
dasherize
Break up a camelize string and seperate with dashes
delete
Delete runes in str matching the pattern, similiar to the delete string feature in Ruby
endsWith
Checks if a string ends with the given suffix.
ensureLeft
Ensure string starts with prefix
ensureRight
Ensure string ends with suffix
first
Grabs a section from the beginning of the string, the size of the section is determine by the given indicated value.
hashCode
Determine the hashcode of a string, algorithm matches the hashCode method available in a Java String class
hasLowercase
Checks if value is contains only lowercase values.
hasUppercase
Checks if value is contains only uppercase values.
indexOf
Finds position of first occurrence of a string within another.
If no match is found boolean false is returned.
There is a second optional parameter, position offset where to begin the search where left most value is index 0.
MultiByte
Case In-sensitive
isAscii
Checks if value contains valid ASCII values only. Optional parameter to allow only printable characters
isAlpha
Checks if value is contains alpha values only.
isAlphaNumeric
Checks if value is contains alphanumeric values only
isAlphaNumericSpace
Checks if value is contains alphanumeric values only including space(s).
isAlphaNumericSpaceDash
Checks if value is contains alphanumeric values only including space(s) and dash(es).
isBase64
Checks if value is a valid Base64 string
isBlank
Checks if value is blank (alias to isEmpty), if string contains whitespace only it is considered empty.
isDate
Checks if value is valid date based on the PHP function strtotime.
Requirement, default timezone must be set first
isDecimal
Checks if value is contains decimal value, whole numbers are considered valid.
isEmail
Checks if value is a valid email.
isEmpty
Checks if value is empty, if string contains whitespace only it is considered empty.
isHash
Checks if value is empty, if string contains whitespace only it is considered empty.
isHexColor
Checks if value is valid Hex Color.
isHexDecimal
Checks if value is hexdecimal.
isIsbn10
Determines if value is valid ISBN10
isIsbn13
Determines if value is valid ISBN13
isIPv4
Checks if value is a valid IP, IPv4.
isIPv6
Checks if value is a valid IP, IPv6.
isJson
Determines if value is valid JSON
isNumber
Checks if value is a whole number, can be a negative number but can not be a decimal number.
isMultiByte
Checks if value is MultiByte
isLatitude
Checks if value is valid Latitude value
isLongitude
Checks if value is valid Longitude value
isRgbColor
Checks if value is valid RGB Color
isSemver
Checks if value is a valid semver format, see http://semver.org/
isUrl
Checks if value is contains a valid URL
join
Concatenates the elements of a to create a single string. The separator string sep is placed between elements in the resulting string. If there is an existing value it is over-written. Default seperator is a comma, if no separator is required then use a blank string.
Uses default separator a comma
Uses a pipe as the separator
No separator, use of a blank strinng
last
Grabs a section from the end of the string, the size of the section is determine by the given indicated value.
lastIndexOf
Finds position of last occurrence of a string within another
If no match is found boolean false is returned.
There is a second optional parameter, position offset where to begin the search where left most value is index 0.
MultiByte
Case In-sensitive
length
Find the length of the string
Multibyte
lineCount
Count the number of lines based line feed, \n.
lowercase
Ensure the string is entirely lower case
lowercaseFirst
First letter of the string is lower cased
padBoth
Pad string on both sides with indicated value
Padding with an even amount
Padding with an odd amount, the extra character is addded to the end of the string
padLeft
Pad string on left side with indicated string value and number of times to pad with
padRight
Pad string on right side with indicated string value and number of times to pad with
randomAlpha
Generate a random alpha value, default length of 10 characters.
randomNumeric
Generate a random string value containing only numeric values, default length of 10 characters. It is important to note this is a string value because otherwise if a value with leading zeros such as 0123456789 would then be 123456789 as type int; but, then would not be length of 10 characters (or the desired indicated expected length)
randomAlphaNumeric
Generate a random alphanumeric value, default length of 10 characters.
repeat
Returns a string repeated n times.
replaceAccents
Replace characters with accents with the same character without accents.
removeAscii
Remove non Ascii characters
removeWhitespace
Remove any whitespace from the string (before, after and any in between)
replace
Match and replace string(s)
Multiple replace
No Match NOT Case-Insensitive
Match Case-Insensitive
MultiByte
reverse
MultiByte
sentenceCount
Count the number of sentences based sentences ending with one the following: . ! or ?
split
Explode string into an array default delimiter is comma
startsWith
Checks if a string starts with the specified suffix.
stripPunctuation
Remove all of the punctuation
stripTags
Remove HTML and PHP tags from a string
Optional second paramter to ignore tags (tags not to be to removed)
substring
Find a portion of a string based on postioning (index position in the string) and length of the portion
MultiByte
swapCase
Swap the case of each character.
toBoolean
Converts a logical truth string to boolean.
trim
Remove whitespace both right and left side of the string
trimLeft
Remove whitespace left of the string
trimRight
Remove whitespace right of the string
truncate
Shorten right side of string by the specified indicated amount
truncateMatch
Shorten string left or right side if given substring is match
Case In-sensitive
uppercase
Ensure entire string is uppercase
uppercaseWords
Ensure entire string is uppercase
width
Find the width of the string this is different then length for multibyte strings
wordCount
Count the number of words.
Basic Functions
setstring
Setting the string you want to apply string manipulations on, this will set the orginal value as well.
php $s = new Stringizer("dummy-value"); $s->getString(); php $s = new Stringizer("dummy-value"); $s->getStringOriginal(); php $s = new Stringizer("dummy-value"); echo ($s); // this will output current state, defaults to using the PHP built __toString method php $s = new Stringizer("dummy-value"); $s->setEncoding("UTF-8"); $s->getEncoding(); // UTF-8 php $s = new Stringizer("dummy-value"); $s->getEncoding(); // Outputs your default encoding based mb_internal_encoding