mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-13 08:44:01 +02:00
Update readme with OO methods
This commit is contained in:
58
README.md
58
README.md
@@ -81,7 +81,7 @@ method in Stringy\StaticStringy. For all others, they're found in Stringy\String
|
|||||||
|
|
||||||
##### create
|
##### create
|
||||||
|
|
||||||
S->create(string $str, [, $encoding ])
|
$stringy = S::create(string $str, [, $encoding ])
|
||||||
|
|
||||||
Creates a Stringy object and assigns both str and encoding properties
|
Creates a Stringy object and assigns both str and encoding properties
|
||||||
the supplied values. If $encoding is not specified, it defaults to
|
the supplied values. If $encoding is not specified, it defaults to
|
||||||
@@ -93,6 +93,8 @@ S::create('fòô bàř', 'UTF-8'); // 'fòô bàř'
|
|||||||
|
|
||||||
##### upperCaseFirst
|
##### upperCaseFirst
|
||||||
|
|
||||||
|
$stringy->upperCaseFirst();
|
||||||
|
|
||||||
S::upperCaseFirst(string $str [, string $encoding ])
|
S::upperCaseFirst(string $str [, string $encoding ])
|
||||||
|
|
||||||
Converts the first character of the supplied string to upper case, with
|
Converts the first character of the supplied string to upper case, with
|
||||||
@@ -105,6 +107,8 @@ S::upperCaseFirst('σ test', 'UTF-8'); // 'Σ test'
|
|||||||
|
|
||||||
##### lowerCaseFirst
|
##### lowerCaseFirst
|
||||||
|
|
||||||
|
$stringy->lowerCaseFirst();
|
||||||
|
|
||||||
S::lowerCaseFirst(string $str [, string $encoding ])
|
S::lowerCaseFirst(string $str [, string $encoding ])
|
||||||
|
|
||||||
Converts the first character of the supplied string to lower case, with
|
Converts the first character of the supplied string to lower case, with
|
||||||
@@ -117,6 +121,8 @@ S::lowerCaseFirst('Σ test', 'UTF-8'); // 'σ test'
|
|||||||
|
|
||||||
##### camelize
|
##### camelize
|
||||||
|
|
||||||
|
$stringy->camelize();
|
||||||
|
|
||||||
S::camelize(string $str [, string $encoding ])
|
S::camelize(string $str [, string $encoding ])
|
||||||
|
|
||||||
Returns a camelCase version of a supplied string, with multibyte support.
|
Returns a camelCase version of a supplied string, with multibyte support.
|
||||||
@@ -130,6 +136,8 @@ S::camelize('Camel-Case'); // 'camelCase'
|
|||||||
|
|
||||||
##### upperCamelize
|
##### upperCamelize
|
||||||
|
|
||||||
|
$stringy->upperCamelize();
|
||||||
|
|
||||||
S::upperCamelize(string $str [, string $encoding ])
|
S::upperCamelize(string $str [, string $encoding ])
|
||||||
|
|
||||||
Returns an UpperCamelCase version of a supplied string, with multibyte
|
Returns an UpperCamelCase version of a supplied string, with multibyte
|
||||||
@@ -143,6 +151,8 @@ S::upperCamelize('Upper Camel-Case'); // 'UpperCamelCase'
|
|||||||
|
|
||||||
##### dasherize
|
##### dasherize
|
||||||
|
|
||||||
|
$stringy->dasherize();
|
||||||
|
|
||||||
S::dasherize(string $str [, string $encoding ])
|
S::dasherize(string $str [, string $encoding ])
|
||||||
|
|
||||||
Returns a lowercase and trimmed string seperated by dashes, with
|
Returns a lowercase and trimmed string seperated by dashes, with
|
||||||
@@ -157,6 +167,8 @@ S::dasherize('TestDCase'); // 'test-d-case'
|
|||||||
|
|
||||||
##### underscored
|
##### underscored
|
||||||
|
|
||||||
|
$stringy->underscored();
|
||||||
|
|
||||||
S::underscored(string $str [, string $encoding ])
|
S::underscored(string $str [, string $encoding ])
|
||||||
|
|
||||||
Returns a lowercase and trimmed string seperated by underscores, with
|
Returns a lowercase and trimmed string seperated by underscores, with
|
||||||
@@ -171,6 +183,8 @@ S::underscored('TestUCase'); // 'test_u_case'
|
|||||||
|
|
||||||
##### swapCase
|
##### swapCase
|
||||||
|
|
||||||
|
$stringy->swapCase();
|
||||||
|
|
||||||
S::swapCase(string $str [, string $encoding ])
|
S::swapCase(string $str [, string $encoding ])
|
||||||
|
|
||||||
Returns a case swapped version of a string.
|
Returns a case swapped version of a string.
|
||||||
@@ -182,6 +196,8 @@ S::swapCase('Ντανιλ', 'UTF-8'); // 'νΤΑΝΙΛ'
|
|||||||
|
|
||||||
##### titleize
|
##### titleize
|
||||||
|
|
||||||
|
$stringy->titleize([ string $encoding ])
|
||||||
|
|
||||||
S::titleize(string $str [, array $ignore [, string $encoding ]])
|
S::titleize(string $str [, array $ignore [, string $encoding ]])
|
||||||
|
|
||||||
Capitalizes the first letter of each word in a string, after trimming.
|
Capitalizes the first letter of each word in a string, after trimming.
|
||||||
@@ -198,6 +214,8 @@ S::titleize('i like to watch DVDs at home', $ignore, 'UTF-8');
|
|||||||
|
|
||||||
##### humanize
|
##### humanize
|
||||||
|
|
||||||
|
$stringy->humanize()
|
||||||
|
|
||||||
S::humanize(string $str [, string $encoding ])
|
S::humanize(string $str [, string $encoding ])
|
||||||
|
|
||||||
Capitalizes the first word of a string, replaces underscores with spaces,
|
Capitalizes the first word of a string, replaces underscores with spaces,
|
||||||
@@ -210,6 +228,8 @@ S::humanize('author_id'); // 'Author'
|
|||||||
|
|
||||||
##### tidy
|
##### tidy
|
||||||
|
|
||||||
|
$stringy->tidy()
|
||||||
|
|
||||||
S::tidy(string $str)
|
S::tidy(string $str)
|
||||||
|
|
||||||
Replaces smart quotes, ellipsis characters, and dashes from Windows-1252
|
Replaces smart quotes, ellipsis characters, and dashes from Windows-1252
|
||||||
@@ -222,6 +242,8 @@ S::tidy('“I see…”'); // '"I see..."'
|
|||||||
|
|
||||||
##### collapseWhitespace
|
##### collapseWhitespace
|
||||||
|
|
||||||
|
$stringy->collapseWhitespace()
|
||||||
|
|
||||||
S::collapseWhitespace(string $str)
|
S::collapseWhitespace(string $str)
|
||||||
|
|
||||||
Trims the string and replaces consecutive whitespace characters with a
|
Trims the string and replaces consecutive whitespace characters with a
|
||||||
@@ -234,6 +256,8 @@ S::collapseWhitespace(' Ο συγγραφέας '); // 'Ο συγγρα
|
|||||||
|
|
||||||
##### standardize
|
##### standardize
|
||||||
|
|
||||||
|
$stringy->standardize()
|
||||||
|
|
||||||
S::standardize(string $str)
|
S::standardize(string $str)
|
||||||
|
|
||||||
Converts some non-ASCII characters to their closest ASCII counterparts.
|
Converts some non-ASCII characters to their closest ASCII counterparts.
|
||||||
@@ -245,6 +269,8 @@ S::standardize('fòô bàř'); // 'foo bar'
|
|||||||
|
|
||||||
##### pad
|
##### pad
|
||||||
|
|
||||||
|
$stringy->pad(int $length [, string $padStr = ' ' [, string $padType = 'right' ]])
|
||||||
|
|
||||||
S::pad(string $str , int $length [, string $padStr = ' ' [, string $padType = 'right' [, string $encoding ]]])
|
S::pad(string $str , int $length [, string $padStr = ' ' [, string $padType = 'right' [, string $encoding ]]])
|
||||||
|
|
||||||
Pads a string to a given length with another string. If length is less
|
Pads a string to a given length with another string. If length is less
|
||||||
@@ -260,6 +286,8 @@ S::pad('fòô bàř', 10, '¬ø', 'left', 'UTF-8'); // '¬ø¬fòô bàř'
|
|||||||
|
|
||||||
##### padLeft
|
##### padLeft
|
||||||
|
|
||||||
|
$stringy->padLeft(int $length [, string $padStr = ' ' ])
|
||||||
|
|
||||||
S::padLeft(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])
|
S::padLeft(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])
|
||||||
|
|
||||||
Returns a new string of a given length such that the beginning of the
|
Returns a new string of a given length such that the beginning of the
|
||||||
@@ -272,6 +300,8 @@ S::padLeft('foo bar', 9, ' '); // ' foo bar'
|
|||||||
|
|
||||||
##### padRight
|
##### padRight
|
||||||
|
|
||||||
|
$stringy->padRight(int $length [, string $padStr = ' ' ])
|
||||||
|
|
||||||
S::padRight(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])
|
S::padRight(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])
|
||||||
|
|
||||||
Returns a new string of a given length such that the end of the string is
|
Returns a new string of a given length such that the end of the string is
|
||||||
@@ -284,6 +314,8 @@ S::padRight('foo bar', 10, '_*'); // 'foo bar_*_'
|
|||||||
|
|
||||||
##### padBoth
|
##### padBoth
|
||||||
|
|
||||||
|
$stringy->padBoth(int $length [, string $padStr = ' ' ])
|
||||||
|
|
||||||
S::padBoth(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])
|
S::padBoth(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])
|
||||||
|
|
||||||
Returns a new string of a given length such that both sides of the string
|
Returns a new string of a given length such that both sides of the string
|
||||||
@@ -296,6 +328,8 @@ S::padBoth('foo bar', 9, ' '); // ' foo bar '
|
|||||||
|
|
||||||
##### startsWith
|
##### startsWith
|
||||||
|
|
||||||
|
$stringy->startsWith(string $substring [, boolean $caseSensitive = true ])
|
||||||
|
|
||||||
S::startsWith(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])
|
S::startsWith(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])
|
||||||
|
|
||||||
Returns true if the string $str begins with $substring, false otherwise.
|
Returns true if the string $str begins with $substring, false otherwise.
|
||||||
@@ -309,6 +343,8 @@ S::startsWith('FÒÔ bàřs', 'fòô bàř', false, 'UTF-8'); // true
|
|||||||
|
|
||||||
##### endsWith
|
##### endsWith
|
||||||
|
|
||||||
|
$stringy->endsWith(string $substring [, boolean $caseSensitive = true ])
|
||||||
|
|
||||||
S::endsWith(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])
|
S::endsWith(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])
|
||||||
|
|
||||||
Returns true if the string $str ends with $substring, false otherwise.
|
Returns true if the string $str ends with $substring, false otherwise.
|
||||||
@@ -322,6 +358,8 @@ S::endsWith('FÒÔ bàřs', 'àřs', true, 'UTF-8'); // true
|
|||||||
|
|
||||||
##### toSpaces
|
##### toSpaces
|
||||||
|
|
||||||
|
$stringy->toSpaces([ tabLength = 4 ])
|
||||||
|
|
||||||
S::toSpaces(string $str, [, int $tabLength = 4 ])
|
S::toSpaces(string $str, [, int $tabLength = 4 ])
|
||||||
|
|
||||||
Converts each tab in a string to some number of spaces, as defined by
|
Converts each tab in a string to some number of spaces, as defined by
|
||||||
@@ -334,6 +372,8 @@ S::toSpaces(' String speech = "Hi"') // ' String speech = "Hi"'
|
|||||||
|
|
||||||
##### toTabs
|
##### toTabs
|
||||||
|
|
||||||
|
$stringy->toTabs([ tabLength = 4 ])
|
||||||
|
|
||||||
S::toTabs(string $str, [, int $tabLength = 4 ])
|
S::toTabs(string $str, [, int $tabLength = 4 ])
|
||||||
|
|
||||||
Converts each occurence of some consecutive number of spaces, as defined
|
Converts each occurence of some consecutive number of spaces, as defined
|
||||||
@@ -347,6 +387,8 @@ S::toTabs(' fòô bàř') // ' fòô bàř'
|
|||||||
|
|
||||||
##### slugify
|
##### slugify
|
||||||
|
|
||||||
|
$stringy->slugify()
|
||||||
|
|
||||||
S::slugify(string $str)
|
S::slugify(string $str)
|
||||||
|
|
||||||
Converts the supplied text into an URL slug. This includes replacing
|
Converts the supplied text into an URL slug. This includes replacing
|
||||||
@@ -361,6 +403,8 @@ S::slugify('Using strings like fòô bàř') // 'using-strings-like-foo-bar'
|
|||||||
|
|
||||||
##### contains
|
##### contains
|
||||||
|
|
||||||
|
$stringy->contains(string $needle)
|
||||||
|
|
||||||
S::contains(string $haystack, string $needle [, string $encoding ])
|
S::contains(string $haystack, string $needle [, string $encoding ])
|
||||||
|
|
||||||
Returns true if $haystack contains $needle, false otherwise.
|
Returns true if $haystack contains $needle, false otherwise.
|
||||||
@@ -372,6 +416,8 @@ S::contains('Ο συγγραφέας είπε', 'συγγραφέας', 'UTF-8')
|
|||||||
|
|
||||||
##### surround
|
##### surround
|
||||||
|
|
||||||
|
$stringy->surround(string $substring)
|
||||||
|
|
||||||
S::surround(string $str, string $substring)
|
S::surround(string $str, string $substring)
|
||||||
|
|
||||||
Surrounds a string with the given substring.
|
Surrounds a string with the given substring.
|
||||||
@@ -383,6 +429,8 @@ S::surround(' ͜ ', 'ʘ'); // 'ʘ ͜ ʘ'
|
|||||||
|
|
||||||
##### insert
|
##### insert
|
||||||
|
|
||||||
|
$stringy->insert(int $index, string $substring)
|
||||||
|
|
||||||
S::insert(string $str, int $index, string $substring [, string $encoding ])
|
S::insert(string $str, int $index, string $substring [, string $encoding ])
|
||||||
|
|
||||||
Inserts $substring into $str at the $index provided.
|
Inserts $substring into $str at the $index provided.
|
||||||
@@ -394,6 +442,8 @@ S::insert('fòô bà', 'ř', 6, 'UTF-8'); // 'fòô bàř'
|
|||||||
|
|
||||||
##### safeTruncate
|
##### safeTruncate
|
||||||
|
|
||||||
|
$stringy->safeTruncate(int $length, [, string $substring = '' ])
|
||||||
|
|
||||||
S::safeTruncate(string $str, int $length, [, string $substring = '' [, string $encoding ]])
|
S::safeTruncate(string $str, int $length, [, string $substring = '' [, string $encoding ]])
|
||||||
|
|
||||||
Truncates the string to a given length, while ensuring that it does not
|
Truncates the string to a given length, while ensuring that it does not
|
||||||
@@ -408,6 +458,8 @@ S::safeTruncate('What are your plans today?', 22, '...'); // 'What are your pla
|
|||||||
|
|
||||||
##### reverse
|
##### reverse
|
||||||
|
|
||||||
|
$stringy->reverse()
|
||||||
|
|
||||||
S::reverse(string $str, [, string $encoding ])
|
S::reverse(string $str, [, string $encoding ])
|
||||||
|
|
||||||
Reverses a string. A multibyte version of strrev.
|
Reverses a string. A multibyte version of strrev.
|
||||||
@@ -419,6 +471,8 @@ S::reverse('fòô bàř', 'UTF-8'); // 'řàb ôòf'
|
|||||||
|
|
||||||
##### shuffle
|
##### shuffle
|
||||||
|
|
||||||
|
$stringy->shuffle()
|
||||||
|
|
||||||
S::shuffle(string $str [, string $encoding ])
|
S::shuffle(string $str [, string $encoding ])
|
||||||
|
|
||||||
A multibyte str_shuffle function. It randomizes the order of characters
|
A multibyte str_shuffle function. It randomizes the order of characters
|
||||||
@@ -431,6 +485,8 @@ S::shuffle('fòô bàř', 'UTF-8') // 'àôřb òf'
|
|||||||
|
|
||||||
##### trim
|
##### trim
|
||||||
|
|
||||||
|
$stringy->trim()
|
||||||
|
|
||||||
S::trim(string $str)
|
S::trim(string $str)
|
||||||
|
|
||||||
Trims $str. An alias for PHP's trim() function.
|
Trims $str. An alias for PHP's trim() function.
|
||||||
|
Reference in New Issue
Block a user