:accept: Stringy - A PHP string manipulation library with multibyte support, performance optimized

Overview

Build Status codecov.io Codacy Badge Latest Stable Version Total Downloads License Donate to this project using Paypal Donate to this project using Patreon

🉑 Stringy

A PHP string manipulation library with multibyte support. Compatible with PHP 7+

100% compatible with the original "Stringy" library, but this fork is optimized for performance and is using PHP 7+ features.

s('string')->toTitleCase()->ensureRight('y') == 'Stringy'

Why?

In part due to a lack of multibyte support (including UTF-8) across many of PHP's standard string functions. But also to offer an OO wrapper around the mbstring module's multibyte-compatible functions. Stringy handles some quirks, provides additional functionality, and hopefully makes strings a little easier to work with!

// Standard library
strtoupper('fòôbàř');       // 'FòôBàř'
strlen('fòôbàř');           // 10

// mbstring
mb_strtoupper('fòôbàř');    // 'FÒÔBÀŘ'
mb_strlen('fòôbàř');        // '6'

// Stringy
$stringy = Stringy\Stringy::create('fòôbàř');
$stringy->toUpperCase();    // 'FÒÔBÀŘ'
$stringy->length();         // '6'

Alternative

If you like a more Functional Way to edit strings, then you can take a look at voku/portable-utf8, also "voku/Stringy" used the functions from the "Portable UTF-8"-Class but in a more Object Oriented Way.

// Portable UTF-8
use voku\helper\UTF8;
UTF8::strtoupper('fòôbàř');    // 'FÒÔBÀŘ'
UTF8::strlen('fòôbàř');        // '6'

Installation via "composer require"

composer require voku/stringy

Installation via composer (manually)

If you're using Composer to manage dependencies, you can include the following in your composer.json file:

"require": {
    "voku/stringy": "~6.0"
}

Then, after running composer update or php composer.phar update, you can load the class using Composer's autoloading:

require 'vendor/autoload.php';

Otherwise, you can simply require the file directly:

require_once 'path/to/Stringy/src/Stringy.php';

And in either case, I'd suggest using an alias.

use Stringy\Stringy as S;

OO and Chaining

The library offers OO method chaining, as seen below:

use Stringy\Stringy as S;
echo S::create('fòô     bàř')->collapseWhitespace()->swapCase(); // 'FÒÔ BÀŘ'

Stringy\Stringy has a __toString() method, which returns the current string when the object is used in a string context, ie: (string) S::create('foo') // 'foo'

Implemented Interfaces

Stringy\Stringy implements the IteratorAggregate interface, meaning that foreach can be used with an instance of the class:

$stringy = S::create('fòôbàř');
foreach ($stringy as $char) {
    echo $char;
}
// 'fòôbàř'

It implements the Countable interface, enabling the use of count() to retrieve the number of characters in the string:

$stringy = S::create('fòô');
count($stringy);  // 3

Furthermore, the ArrayAccess interface has been implemented. As a result, isset() can be used to check if a character at a specific index exists. And since Stringy\Stringy is immutable, any call to offsetSet or offsetUnset will throw an exception. offsetGet has been implemented, however, and accepts both positive and negative indexes. Invalid indexes result in an OutOfBoundsException.

$stringy = S::create('bàř');
echo $stringy[2];     // 'ř'
echo $stringy[-2];    // 'à'
isset($stringy[-4]);  // false

$stringy[3];          // OutOfBoundsException
$stringy[2] = 'a';    // Exception

PHP Class Call Creation

As of PHP 5.6+, use function is available for importing functions. Stringy exposes a namespaced function, Stringy\create, which emits the same behaviour as Stringy\Stringy::create().

use function Stringy\create as s;

// Instead of: S::create('fòô     bàř')
s('fòô     bàř')->collapseWhitespace()->swapCase();

Class methods

create(mixed $str [, $encoding ])

Creates a Stringy object and assigns both str and encoding properties the supplied values. $str is cast to a string prior to assignment, and if $encoding is not specified, it defaults to mb_internal_encoding(). It then returns the initialized object. Throws an InvalidArgumentException if the first argument is an array or object without a __toString method.

$stringy = S::create('fòôbàř', 'UTF-8'); // 'fòôbàř'

If you need a collection of Stringy objects you can use the S::collection() method.

$stringyCollection = \Stringy\collection(['fòôbàř', 'lall', 'öäü']);

Instance Methods

Stringy objects are immutable. All examples below make use of PHP 5.6 function importing, and PHP 5.4 short array syntax. They also assume the encoding returned by mb_internal_encoding() is UTF-8. For further details, see the documentation for the create method above.

after afterFirst afterFirstIgnoreCase afterLast
afterLastIgnoreCase append appendPassword appendRandomString
appendStringy appendUniqueIdentifier at base64Decode
base64Encode bcrypt before beforeFirst
beforeFirstIgnoreCase beforeLast beforeLastIgnoreCase between
callUserFunction camelize capitalizePersonalName chars
chunk chunkCollection collapseWhitespace contains
containsAll containsAny containsBom count
countSubstr crc32 create crypt
dasherize decrypt delimit encode
encrypt endsWith endsWithAny ensureLeft
ensureRight escape explode explodeCollection
extractText first format getEncoding
getIterator hardWrap hasLowerCase hasUpperCase
hash hexDecode hexEncode htmlDecode
htmlEncode humanize in indexOf
indexOfIgnoreCase indexOfLast indexOfLastIgnoreCase insert
is isAlpha isAlphanumeric isAscii
isBase64 isBinary isBlank isBom
isEmail isEmpty isEquals isEqualsCaseInsensitive
isEqualsCaseSensitive isHexadecimal isHtml isJson
isLowerCase isNotEmpty isNumeric isPrintable
isPunctuation isSerialized isSimilar isUpperCase
isUrl isUtf8 isUtf16 isUtf32
isWhitespace jsonSerialize kebabCase last
lastSubstringOf lastSubstringOfIgnoreCase length lineWrap
lineWrapAfterWord lines linesCollection longestCommonPrefix
longestCommonSubstring longestCommonSuffix lowerCaseFirst matchCaseInsensitive
matchCaseSensitive md5 newLineToHtmlBreak nth
offsetExists offsetGet offsetSet offsetUnset
pad padBoth padLeft padRight
pascalCase prepend prependStringy regexReplace
removeHtml removeHtmlBreak removeLeft removeRight
removeXss repeat replace replaceAll
replaceBeginning replaceEnding replaceFirst replaceLast
reverse safeTruncate setInternalEncoding sha1
sha256 sha512 shortenAfterWord shuffle
similarity slice slugify snakeCase
snakeize softWrap split splitCollection
startsWith startsWithAny strip stripWhitespace
stripeCssMediaQueries stripeEmptyHtmlTags studlyCase substr
substring substringOf substringOfIgnoreCase surround
swapCase tidy titleize titleizeForHumans
toAscii toBoolean toLowerCase toSpaces
toString toTabs toTitleCase toTransliterate
toUpperCase trim trimLeft trimRight
truncate underscored upperCamelize upperCaseFirst
urlDecode urlDecodeMulti urlDecodeRaw urlDecodeRawMulti
urlEncode urlEncodeRaw urlify utf8ify
words wordsCollection wrap

after(string $string): static

Return part of the string occurring after a specific string.

EXAMPLE: s('宮本 茂')->after('本'); // ' 茂'

Parameters:

  • string $string <p>The delimiting string.</p>

Return:

  • static

afterFirst(string $separator): static

Gets the substring after the first occurrence of a separator.

If no match is found returns new empty Stringy object.

EXAMPLE: s('')->afterFirst('b'); // '>'

Parameters:

  • string $separator

Return:

  • static

afterFirstIgnoreCase(string $separator): static

Gets the substring after the first occurrence of a separator.

If no match is found returns new empty Stringy object.

EXAMPLE: s('')->afterFirstIgnoreCase('b'); // '>'

Parameters:

  • string $separator

Return:

  • static

afterLast(string $separator): static

Gets the substring after the last occurrence of a separator.

If no match is found returns new empty Stringy object.

EXAMPLE: s('')->afterLast('b'); // '>'

Parameters:

  • string $separator

Return:

  • static

afterLastIgnoreCase(string $separator): static

Gets the substring after the last occurrence of a separator.

If no match is found returns new empty Stringy object.

EXAMPLE: s('')->afterLastIgnoreCase('b'); // '>'

Parameters:

  • string $separator

Return:

  • static

append(string $suffix): static

Returns a new string with $suffix appended.

EXAMPLE: s('fòô')->append('bàř'); // 'fòôbàř'

Parameters:

  • string ...$suffix <p>The string to append.</p>

Return:

  • static <p>Object with appended $suffix.</p>

appendPassword(int $length): static

Append an password (limited to chars that are good readable).

EXAMPLE: s('')->appendPassword(8); // e.g.: '89bcdfgh'

Parameters:

  • int $length <p>Length of the random string.</p>

Return:

  • static <p>Object with appended password.</p>

appendRandomString(int $length, string $possibleChars): static

Append an random string.

EXAMPLE: s('')->appendUniqueIdentifier(5, 'ABCDEFGHI'); // e.g.: 'CDEHI'

Parameters:

  • int $length <p>Length of the random string.</p>
  • string $possibleChars [optional] <p>Characters string for the random selection.</p>

Return:

  • static <p>Object with appended random string.</p>

appendStringy(\CollectionStringy|static $suffix): static

Returns a new string with $suffix appended.

EXAMPLE:

Parameters:

  • CollectionStringy<int, static>|static ...$suffix <p>The Stringy objects to append.</p>

Return:

  • static <p>Object with appended $suffix.</p>

appendUniqueIdentifier(int|string $entropyExtra, bool $md5): static

Append an unique identifier.

EXAMPLE: s('')->appendUniqueIdentifier(); // e.g.: '1f3870be274f6c49b3e31a0c6728957f'

Parameters:

  • int|string $entropyExtra [optional] <p>Extra entropy via a string or int value.</p>
  • bool $md5 [optional] <p>Return the unique identifier as md5-hash? Default: true</p>

Return:

  • static <p>Object with appended unique identifier as md5-hash.</p>

at(int $index): static

Returns the character at $index, with indexes starting at 0.

EXAMPLE: s('fòôbàř')->at(3); // 'b'

Parameters:

  • int $index <p>Position of the character.</p>

Return:

  • static <p>The character at $index.</p>

base64Decode(): self

Decode the base64 encoded string.

EXAMPLE:

Parameters: nothing

Return:

  • self

base64Encode(): self

Encode the string to base64.

EXAMPLE:

Parameters: nothing

Return:

  • self

bcrypt(array $options):

Parameters:

  • array $options

Return:

  • self

before(string $string): static

Return part of the string occurring before a specific string.

EXAMPLE:

Parameters:

  • string $string <p>The delimiting string.</p>

Return:

  • static

beforeFirst(string $separator): static

Gets the substring before the first occurrence of a separator.

If no match is found returns new empty Stringy object.

EXAMPLE: s('')->beforeFirst('b'); // '</'

Parameters:

  • string $separator

Return:

  • static

beforeFirstIgnoreCase(string $separator): static

Gets the substring before the first occurrence of a separator.

If no match is found returns new empty Stringy object.

EXAMPLE: s('')->beforeFirstIgnoreCase('b'); // '</'

Parameters:

  • string $separator

Return:

  • static

beforeLast(string $separator): static

Gets the substring before the last occurrence of a separator.

If no match is found returns new empty Stringy object.

EXAMPLE: s('')->beforeLast('b'); // '</'

Parameters:

  • string $separator

Return:

  • static

beforeLastIgnoreCase(string $separator): static

Gets the substring before the last occurrence of a separator.

If no match is found returns new empty Stringy object.

EXAMPLE: s('')->beforeLastIgnoreCase('b'); // '</'

Parameters:

  • string $separator

Return:

  • static

between(string $start, string $end, int $offset): static

Returns the substring between $start and $end, if found, or an empty string. An optional offset may be supplied from which to begin the search for the start string.

EXAMPLE: s('{foo} and {bar}')->between('{', '}'); // 'foo'

Parameters:

  • string $start <p>Delimiter marking the start of the substring.</p>
  • string $end <p>Delimiter marking the end of the substring.</p>
  • int $offset [optional] <p>Index from which to begin the search. Default: 0</p>

Return:

  • static <p>Object whose $str is a substring between $start and $end.</p>

callUserFunction(callable $function, mixed $parameter): static

Call a user function.

EXAMPLE: S::create('foo bar lall')->callUserFunction(static function ($str) { return UTF8::str_limit($str, 8); })->toString(); // "foo bar…"

Parameters:

  • callable $function
  • mixed ...$parameter

Return:

  • static <p>Object having a $str changed via $function.</p>

camelize(): static

Returns a camelCase version of the string. Trims surrounding spaces, capitalizes letters following digits, spaces, dashes and underscores, and removes spaces, dashes, as well as underscores.

EXAMPLE: s('Camel-Case')->camelize(); // 'camelCase'

Parameters: nothing

Return:

  • static <p>Object with $str in camelCase.</p>

capitalizePersonalName(): static

Returns the string with the first letter of each word capitalized, except for when the word is a name which shouldn't be capitalized.

EXAMPLE: s('jaap de hoop scheffer')->capitalizePersonName(); // 'Jaap de Hoop Scheffer'

Parameters: nothing

Return:

  • static <p>Object with $str capitalized.</p>

chars(): string[]

Returns an array consisting of the characters in the string.

EXAMPLE: s('fòôbàř')->chars(); // ['f', 'ò', 'ô', 'b', 'à', 'ř']

Parameters: nothing

Return:

  • string[] <p>An array of string chars.</p>

chunk(int $length): static[]

Splits the string into chunks of Stringy objects.

EXAMPLE: s('foobar')->chunk(3); // ['foo', 'bar']

Parameters:

  • int $length [optional] <p>Max character length of each array element.</p>

Return:

  • static[] <p>An array of Stringy objects.</p>

chunkCollection(int $length): CollectionStringy|static[]

Splits the string into chunks of Stringy objects collection.

EXAMPLE:

Parameters:

  • int $length [optional] <p>Max character length of each array element.</p>

Return:

  • \CollectionStringy|static[] <p>An collection of Stringy objects.</p>

collapseWhitespace(): static

Trims the string and replaces consecutive whitespace characters with a single space. This includes tabs and newline characters, as well as multibyte whitespace such as the thin space and ideographic space.

EXAMPLE: s(' Ο συγγραφέας ')->collapseWhitespace(); // 'Ο συγγραφέας'

Parameters: nothing

Return:

  • static <p>Object with a trimmed $str and condensed whitespace.</p>

contains(string $needle, bool $caseSensitive): bool

Returns true if the string contains $needle, false otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.

EXAMPLE: s('Ο συγγραφέας είπε')->contains('συγγραφέας'); // true

Parameters:

  • string $needle <p>Substring to look for.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • bool <p>Whether or not $str contains $needle.</p>

containsAll(string[] $needles, bool $caseSensitive): bool

Returns true if the string contains all $needles, false otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.

EXAMPLE: s('foo & bar')->containsAll(['foo', 'bar']); // true

Parameters:

  • string[] $needles <p>SubStrings to look for.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • bool <p>Whether or not $str contains $needle.</p>

containsAny(string[] $needles, bool $caseSensitive): bool

Returns true if the string contains any $needles, false otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.

EXAMPLE: s('str contains foo')->containsAny(['foo', 'bar']); // true

Parameters:

  • string[] $needles <p>SubStrings to look for.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • bool <p>Whether or not $str contains $needle.</p>

containsBom(): bool

Checks if string starts with "BOM" (Byte Order Mark Character) character.

EXAMPLE: s("\xef\xbb\xbf foobar")->containsBom(); // true

Parameters: nothing

Return:

  • bool <strong>true</strong> if the string has BOM at the start,<br> <strong>false</strong> otherwise

count(): int

Returns the length of the string, implementing the countable interface.

EXAMPLE:

Parameters: nothing

Return:

  • int <p>The number of characters in the string, given the encoding.</p>

countSubstr(string $substring, bool $caseSensitive): int

Returns the number of occurrences of $substring in the given string.

By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.

EXAMPLE: s('Ο συγγραφέας είπε')->countSubstr('α'); // 2

Parameters:

  • string $substring <p>The substring to search for.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • int

crc32(): int

Calculates the crc32 polynomial of a string.

EXAMPLE:

Parameters: nothing

Return:

  • int

create(mixed $str, string $encoding): static

Creates a Stringy object and assigns both str and encoding properties the supplied values. $str is cast to a string prior to assignment, and if $encoding is not specified, it defaults to mb_internal_encoding(). It then returns the initialized object. Throws an InvalidArgumentException if the first argument is an array or object without a __toString method.

Parameters:

  • mixed $str [optional] <p>Value to modify, after being cast to string. Default: ''</p>
  • string $encoding [optional] <p>The character encoding. Fallback: 'UTF-8'</p>

Return:

  • static <p>A Stringy object.</p>

crypt(string $salt): static

One-way string encryption (hashing).

Hash the string using the standard Unix DES-based algorithm or an alternative algorithm that may be available on the system.

PS: if you need encrypt / decrypt, please use static::encrypt($password) and static::decrypt($password)

EXAMPLE:

Parameters:

  • string $salt <p>A salt string to base the hashing on.</p>

Return:

  • static

dasherize(): static

Returns a lowercase and trimmed string separated by dashes. Dashes are inserted before uppercase characters (with the exception of the first character of the string), and in place of spaces as well as underscores.

EXAMPLE: s('fooBar')->dasherize(); // 'foo-bar'

Parameters: nothing

Return:

  • static <p>Object with a dasherized $str</p>

decrypt(string $password): static

Decrypt the string.

EXAMPLE:

Parameters:

  • string $password The key for decrypting

Return:

  • static

delimit(string $delimiter): static

Returns a lowercase and trimmed string separated by the given delimiter.

Delimiters are inserted before uppercase characters (with the exception of the first character of the string), and in place of spaces, dashes, and underscores. Alpha delimiters are not converted to lowercase.

EXAMPLE: s('fooBar')->delimit('::'); // 'foo::bar'

Parameters:

  • string $delimiter <p>Sequence used to separate parts of the string.</p>

Return:

  • static <p>Object with a delimited $str.</p>

encode(string $new_encoding, bool $auto_detect_encoding): static

Encode the given string into the given $encoding + set the internal character encoding.

EXAMPLE:

Parameters:

  • string $new_encoding <p>The desired character encoding.</p>
  • bool $auto_detect_encoding [optional] <p>Auto-detect the current string-encoding</p>

Return:

  • static

encrypt(string $password): static

Encrypt the string.

EXAMPLE:

Parameters:

  • string $password <p>The key for encrypting</p>

Return:

  • static

endsWith(string $substring, bool $caseSensitive): bool

Returns true if the string ends with $substring, false otherwise. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.

EXAMPLE: s('fòôbàř')->endsWith('bàř', true); // true

Parameters:

  • string $substring <p>The substring to look for.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • bool <p>Whether or not $str ends with $substring.</p>

endsWithAny(string[] $substrings, bool $caseSensitive): bool

Returns true if the string ends with any of $substrings, false otherwise.

By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.

EXAMPLE: s('fòôbàř')->endsWithAny(['bàř', 'baz'], true); // true

Parameters:

  • string[] $substrings <p>Substrings to look for.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • bool <p>Whether or not $str ends with $substring.</p>

ensureLeft(string $substring): static

Ensures that the string begins with $substring. If it doesn't, it's prepended.

EXAMPLE: s('foobar')->ensureLeft('http://'); // 'http://foobar'

Parameters:

  • string $substring <p>The substring to add if not present.</p>

Return:

  • static <p>Object with its $str prefixed by the $substring.</p>

ensureRight(string $substring): static

Ensures that the string ends with $substring. If it doesn't, it's appended.

EXAMPLE: s('foobar')->ensureRight('.com'); // 'foobar.com'

Parameters:

  • string $substring <p>The substring to add if not present.</p>

Return:

  • static <p>Object with its $str suffixed by the $substring.</p>

escape(): static

Create a escape html version of the string via "htmlspecialchars()".

EXAMPLE: s('<∂∆ onerror="alert(xss)">')->escape(); // '<∂∆ onerror="alert(xss)">'

Parameters: nothing

Return:

  • static

explode(string $delimiter, int $limit): array<int,static>

Split a string by a string.

EXAMPLE:

Parameters:

  • string $delimiter <p>The boundary string</p>

  • `int $limit [optional]

    The maximum number of elements in the exploded collection.

  • If limit is set and positive, the returned collection will contain a maximum of limit elements with the last element containing the rest of string.

  • If the limit parameter is negative, all components except the last -limit are returned.

  • If the limit parameter is zero, then this is treated as 1`

Return:

  • array<int,static>

explodeCollection(string $delimiter, int $limit): CollectionStringy|static[]

Split a string by a string.

EXAMPLE:

Parameters:

  • string $delimiter <p>The boundary string</p>

  • `int $limit [optional]

    The maximum number of elements in the exploded collection.

  • If limit is set and positive, the returned collection will contain a maximum of limit elements with the last element containing the rest of string.

  • If the limit parameter is negative, all components except the last -limit are returned.

  • If the limit parameter is zero, then this is treated as 1`

Return:

  • \CollectionStringy|static[] <p>An collection of Stringy objects.</p>

extractText(string $search, int|null $length, string $replacerForSkippedText): static

Create an extract from a sentence, so if the search-string was found, it try to centered in the output.

EXAMPLE: $sentence = 'This is only a Fork of Stringy, take a look at the new features.'; s($sentence)->extractText('Stringy'); // '...Fork of Stringy...'

Parameters:

  • string $search
  • int|null $length [optional] <p>Default: null === text->length / 2</p>
  • string $replacerForSkippedText [optional] <p>Default: …</p>

Return:

  • static

first(int $n): static

Returns the first $n characters of the string.

EXAMPLE: s('fòôbàř')->first(3); // 'fòô'

Parameters:

  • int $n <p>Number of characters to retrieve from the start.</p>

Return:

  • static <p>Object with its $str being the first $n chars.</p>

format(mixed $args): static

Return a formatted string via sprintf + named parameters via array syntax.


It will use "sprintf()" so you can use e.g.:

s('There are %d monkeys in the %s')->format(5, 'tree');


s('There are %2$d monkeys in the %1$s')->format('tree', 5);


But you can also use named parameter via array syntax e.g.:

s('There are %:count monkeys in the %:location')->format(['count' => 5, 'location' => 'tree');

EXAMPLE: $input = 'one: %2$d, %1$s: 2, %:text_three: %3$d'; s($input)->format(['text_three' => '%4$s'], 'two', 1, 3, 'three'); // 'One: 1, two: 2, three: 3'

Parameters:

  • mixed ...$args [optional]

Return:

  • static <p>A Stringy object produced according to the formatting string format.</p>

getEncoding(): string

Returns the encoding used by the Stringy object.

EXAMPLE: s('fòôbàř', 'UTF-8')->getEncoding(); // 'UTF-8'

Parameters: nothing

Return:

  • string <p>The current value of the $encoding property.</p>

getIterator(): ArrayIterator

Returns a new ArrayIterator, thus implementing the IteratorAggregate interface. The ArrayIterator's constructor is passed an array of chars in the multibyte string. This enables the use of foreach with instances of Stringy\Stringy.

EXAMPLE:

Parameters: nothing

Return:

  • \ArrayIterator <p>An iterator for the characters in the string.</p>

hardWrap(int $width, string $break): static

Wrap the string after an exact number of characters.

EXAMPLE:

Parameters:

  • int $width <p>Number of characters at which to wrap.</p>
  • string $break [optional] <p>Character used to break the string. | Default: "\n"</p>

Return:

  • static

hasLowerCase(): bool

Returns true if the string contains a lower case char, false otherwise

EXAMPLE: s('fòôbàř')->hasLowerCase(); // true

Parameters: nothing

Return:

  • bool <p>Whether or not the string contains a lower case character.</p>

hasUpperCase(): bool

Returns true if the string contains an upper case char, false otherwise.

EXAMPLE: s('fòôbàř')->hasUpperCase(); // false

Parameters: nothing

Return:

  • bool <p>Whether or not the string contains an upper case character.</p>

hash(string $algorithm): static

Generate a hash value (message digest).

EXAMPLE:

Parameters:

  • string $algorithm <p>Name of selected hashing algorithm (i.e. "md5", "sha256", "haval160,4", etc..)</p>

Return:

  • static

hexDecode(): static

Decode the string from hex.

EXAMPLE:

Parameters: nothing

Return:

  • static

hexEncode(): static

Encode string to hex.

EXAMPLE:

Parameters: nothing

Return:

  • static

htmlDecode(int $flags): static

Convert all HTML entities to their applicable characters.

EXAMPLE: s('&')->htmlDecode(); // '&'

Parameters:

  • `int $flags [optional]

    A bitmask of one or more of the following flags, which specify how to handle quotes and which document type to use. The default is ENT_COMPAT.

Available flags constants
Constant Name Description
ENT_COMPAT Will convert double-quotes and leave single-quotes alone.
ENT_QUOTES Will convert both double and single quotes.
ENT_NOQUOTES Will leave both double and single quotes unconverted.
ENT_HTML401 Handle code as HTML 4.01.
ENT_XML1 Handle code as XML 1.
ENT_XHTML Handle code as XHTML.
ENT_HTML5 Handle code as HTML 5.

`

Return:

  • static <p>Object with the resulting $str after being html decoded.</p>

htmlEncode(int $flags): static

Convert all applicable characters to HTML entities.

EXAMPLE: s('&')->htmlEncode(); // '&'

Parameters:

  • `int $flags [optional]

    A bitmask of one or more of the following flags, which specify how to handle quotes and which document type to use. The default is ENT_COMPAT.

Available flags constants
Constant Name Description
ENT_COMPAT Will convert double-quotes and leave single-quotes alone.
ENT_QUOTES Will convert both double and single quotes.
ENT_NOQUOTES Will leave both double and single quotes unconverted.
ENT_HTML401 Handle code as HTML 4.01.
ENT_XML1 Handle code as XML 1.
ENT_XHTML Handle code as XHTML.
ENT_HTML5 Handle code as HTML 5.

`

Return:

  • static <p>Object with the resulting $str after being html encoded.</p>

humanize(): static

Capitalizes the first word of the string, replaces underscores with spaces, and strips '_id'.

EXAMPLE: s('author_id')->humanize(); // 'Author'

Parameters: nothing

Return:

  • static <p>Object with a humanized $str.</p>

in(string $str, bool $caseSensitive): bool

Determine if the current string exists in another string. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.

EXAMPLE:

Parameters:

  • string $str <p>The string to compare against.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • bool

indexOf(string $needle, int $offset): false|int

Returns the index of the first occurrence of $needle in the string, and false if not found. Accepts an optional offset from which to begin the search.

EXAMPLE: s('string')->indexOf('ing'); // 3

Parameters:

  • string $needle <p>Substring to look for.</p>
  • int $offset [optional] <p>Offset from which to search. Default: 0</p>

Return:

  • false|int <p>The occurrence's <strong>index</strong> if found, otherwise <strong>false</strong>.</p>

indexOfIgnoreCase(string $needle, int $offset): false|int

Returns the index of the first occurrence of $needle in the string, and false if not found. Accepts an optional offset from which to begin the search.

EXAMPLE: s('string')->indexOfIgnoreCase('ING'); // 3

Parameters:

  • string $needle <p>Substring to look for.</p>
  • int $offset [optional] <p>Offset from which to search. Default: 0</p>

Return:

  • false|int <p>The occurrence's <strong>index</strong> if found, otherwise <strong>false</strong>.</p>

indexOfLast(string $needle, int $offset): false|int

Returns the index of the last occurrence of $needle in the string, and false if not found. Accepts an optional offset from which to begin the search. Offsets may be negative to count from the last character in the string.

EXAMPLE: s('foobarfoo')->indexOfLast('foo'); // 10

Parameters:

  • string $needle <p>Substring to look for.</p>
  • int $offset [optional] <p>Offset from which to search. Default: 0</p>

Return:

  • false|int <p>The last occurrence's <strong>index</strong> if found, otherwise <strong>false</strong>.</p>

indexOfLastIgnoreCase(string $needle, int $offset): false|int

Returns the index of the last occurrence of $needle in the string, and false if not found. Accepts an optional offset from which to begin the search. Offsets may be negative to count from the last character in the string.

EXAMPLE: s('fooBarFoo')->indexOfLastIgnoreCase('foo'); // 10

Parameters:

  • string $needle <p>Substring to look for.</p>
  • int $offset [optional] <p>Offset from which to search. Default: 0</p>

Return:

  • false|int <p>The last occurrence's <strong>index</strong> if found, otherwise <strong>false</strong>.</p>

insert(string $substring, int $index): static

Inserts $substring into the string at the $index provided.

EXAMPLE: s('fòôbř')->insert('à', 4); // 'fòôbàř'

Parameters:

  • string $substring <p>String to be inserted.</p>
  • int $index <p>The index at which to insert the substring.</p>

Return:

  • static <p>Object with the resulting $str after the insertion.</p>

is(string $pattern): bool

Returns true if the string contains the $pattern, otherwise false.

WARNING: Asterisks ("") are translated into (".") zero-or-more regular expression wildcards.

EXAMPLE: s('Foo\Bar\Lall')->is('\Bar\'); // true

Parameters:

  • string $pattern <p>The string or pattern to match against.</p>

Return:

  • bool <p>Whether or not we match the provided pattern.</p>

isAlpha(): bool

Returns true if the string contains only alphabetic chars, false otherwise.

EXAMPLE: s('丹尼爾')->isAlpha(); // true

Parameters: nothing

Return:

  • bool <p>Whether or not $str contains only alphabetic chars.</p>

isAlphanumeric(): bool

Returns true if the string contains only alphabetic and numeric chars, false otherwise.

EXAMPLE: s('دانيال1')->isAlphanumeric(); // true

Parameters: nothing

Return:

  • bool <p>Whether or not $str contains only alphanumeric chars.</p>

isAscii(): bool

Checks if a string is 7 bit ASCII.

EXAMPLE: s('白')->isAscii; // false

Parameters: nothing

Return:

  • `bool

    true if it is ASCII
    false otherwise

`

isBase64(bool $emptyStringIsValid): bool

Returns true if the string is base64 encoded, false otherwise.

EXAMPLE: s('Zm9vYmFy')->isBase64(); // true

Parameters:

  • bool $emptyStringIsValid

Return:

  • bool <p>Whether or not $str is base64 encoded.</p>

isBinary(): bool

Check if the input is binary.

.. (is look like a hack).

EXAMPLE: s(01)->isBinary(); // true

Parameters: nothing

Return:

  • bool

isBlank(): bool

Returns true if the string contains only whitespace chars, false otherwise.

EXAMPLE: s("\n\t \v\f")->isBlank(); // true

Parameters: nothing

Return:

  • bool <p>Whether or not $str contains only whitespace characters.</p>

isBom(): bool

Checks if the given string is equal to any "Byte Order Mark".

WARNING: Use "s::string_has_bom()" if you will check BOM in a string.

EXAMPLE: s->("\xef\xbb\xbf")->isBom(); // true

Parameters: nothing

Return:

  • bool <p><strong>true</strong> if the $utf8_chr is Byte Order Mark, <strong>false</strong> otherwise.</p>

isEmail(bool $useExampleDomainCheck, bool $useTypoInDomainCheck, bool $useTemporaryDomainCheck, bool $useDnsCheck): bool

Returns true if the string contains a valid E-Mail address, false otherwise.

EXAMPLE: s('[email protected]')->isEmail(); // true

Parameters:

  • bool $useExampleDomainCheck [optional] <p>Default: false</p>
  • bool $useTypoInDomainCheck [optional] <p>Default: false</p>
  • bool $useTemporaryDomainCheck [optional] <p>Default: false</p>
  • bool $useDnsCheck [optional] <p>Default: false</p>

Return:

  • bool <p>Whether or not $str contains a valid E-Mail address.</p>

isEmpty(): bool

Determine whether the string is considered to be empty.

A variable is considered empty if it does not exist or if its value equals FALSE.

EXAMPLE: s('')->isEmpty(); // true

Parameters: nothing

Return:

  • bool <p>Whether or not $str is empty().</p>

isEquals(string|\Stringy $str): bool

Determine whether the string is equals to $str.

Alias for isEqualsCaseSensitive()

EXAMPLE: s('foo')->isEquals('foo'); // true

Parameters:

  • string|\Stringy ...$str

Return:

  • bool

isEqualsCaseInsensitive(float|int|string|\Stringy $str): bool

Determine whether the string is equals to $str.

EXAMPLE:

Parameters:

  • float|int|string|\Stringy ...$str <p>The string to compare.</p>

Return:

  • bool <p>Whether or not $str is equals.</p>

isEqualsCaseSensitive(float|int|string|\Stringy $str): bool

Determine whether the string is equals to $str.

EXAMPLE:

Parameters:

  • float|int|string|\Stringy ...$str <p>The string to compare.</p>

Return:

  • bool <p>Whether or not $str is equals.</p>

isHexadecimal(): bool

Returns true if the string contains only hexadecimal chars, false otherwise.

EXAMPLE: s('A102F')->isHexadecimal(); // true

Parameters: nothing

Return:

  • bool <p>Whether or not $str contains only hexadecimal chars.</p>

isHtml(): bool

Returns true if the string contains HTML-Tags, false otherwise.

EXAMPLE: s('

foo

')->isHtml(); // true

Parameters: nothing

Return:

  • bool <p>Whether or not $str contains HTML-Tags.</p>

isJson(bool $onlyArrayOrObjectResultsAreValid): bool

Returns true if the string is JSON, false otherwise. Unlike json_decode in PHP 5.x, this method is consistent with PHP 7 and other JSON parsers, in that an empty string is not considered valid JSON.

EXAMPLE: s('{"foo":"bar"}')->isJson(); // true

Parameters:

  • bool $onlyArrayOrObjectResultsAreValid

Return:

  • bool <p>Whether or not $str is JSON.</p>

isLowerCase(): bool

Returns true if the string contains only lower case chars, false otherwise.

EXAMPLE: s('fòôbàř')->isLowerCase(); // true

Parameters: nothing

Return:

  • bool <p>Whether or not $str contains only lower case characters.</p>

isNotEmpty(): bool

Determine whether the string is considered to be NOT empty.

A variable is considered NOT empty if it does exist or if its value equals TRUE.

EXAMPLE: s('')->isNotEmpty(); // false

Parameters: nothing

Return:

  • bool <p>Whether or not $str is empty().</p>

isNumeric(): bool

Determine if the string is composed of numeric characters.

EXAMPLE:

Parameters: nothing

Return:

  • bool

isPrintable(): bool

Determine if the string is composed of printable (non-invisible) characters.

EXAMPLE:

Parameters: nothing

Return:

  • bool

isPunctuation(): bool

Determine if the string is composed of punctuation characters.

EXAMPLE:

Parameters: nothing

Return:

  • bool

isSerialized(): bool

Returns true if the string is serialized, false otherwise.

EXAMPLE: s('a:1:{s:3:"foo";s:3:"bar";}')->isSerialized(); // true

Parameters: nothing

Return:

  • bool <p>Whether or not $str is serialized.</p>

isSimilar(string $str, float $minPercentForSimilarity): bool

Check if two strings are similar.

EXAMPLE:

Parameters:

  • string $str <p>The string to compare against.</p>
  • float $minPercentForSimilarity [optional] <p>The percentage of needed similarity. | Default: 80%</p>

Return:

  • bool

isUpperCase(): bool

Returns true if the string contains only lower case chars, false otherwise.

EXAMPLE: s('FÒÔBÀŘ')->isUpperCase(); // true

Parameters: nothing

Return:

  • bool <p>Whether or not $str contains only lower case characters.</p>

isUrl(bool $disallow_localhost): bool

/** Check if $url is an correct url.

Parameters:

  • bool $disallow_localhost

Return:

  • bool

isUtf8(bool $strict): bool

Checks whether the passed input contains only byte sequences that appear valid UTF-8.

EXAMPLE: s('Iñtërnâtiônàlizætiøn')->isUtf8(); // true // s("Iñtërnâtiônàlizætiøn\xA0\xA1")->isUtf8(); // false

Parameters:

  • bool $strict <p>Check also if the string is not UTF-16 or UTF-32.</p>

Return:

  • bool

isUtf16(): false|int

Check if the string is UTF-16.

Parameters: nothing

Return:

  • false|int <strong>false</strong> if is't not UTF-16,<br> <strong>1</strong> for UTF-16LE,<br> <strong>2</strong> for UTF-16BE

isUtf32(): false|int

Check if the string is UTF-32.

Parameters: nothing

Return:

  • false|int <strong>false</strong> if is't not UTF-32,<br> <strong>1</strong> for UTF-32LE,<br> <strong>2</strong> for UTF-32BE

isWhitespace(): bool

Returns true if the string contains only whitespace chars, false otherwise.

EXAMPLE:

Parameters: nothing

Return:

  • bool <p>Whether or not $str contains only whitespace characters.</p>

jsonSerialize(): string

Returns value which can be serialized by json_encode().

EXAMPLE:

Parameters: nothing

Return:

  • string The current value of the $str property

kebabCase(): static

Convert the string to kebab-case.

EXAMPLE:

Parameters: nothing

Return:

  • static

last(int $n): static

Returns the last $n characters of the string.

EXAMPLE: s('fòôbàř')->last(3); // 'bàř'

Parameters:

  • int $n <p>Number of characters to retrieve from the end.</p>

Return:

  • static <p>Object with its $str being the last $n chars.</p>

lastSubstringOf(string $needle, bool $beforeNeedle): static

Gets the substring after (or before via "$beforeNeedle") the last occurrence of the "$needle".

If no match is found returns new empty Stringy object.

EXAMPLE:

Parameters:

  • string $needle <p>The string to look for.</p>
  • bool $beforeNeedle [optional] <p>Default: false</p>

Return:

  • static

lastSubstringOfIgnoreCase(string $needle, bool $beforeNeedle): static

Gets the substring after (or before via "$beforeNeedle") the last occurrence of the "$needle".

If no match is found returns new empty Stringy object.

EXAMPLE:

Parameters:

  • string $needle <p>The string to look for.</p>
  • bool $beforeNeedle [optional] <p>Default: false</p>

Return:

  • static

length(): int

Returns the length of the string.

EXAMPLE: s('fòôbàř')->length(); // 6

Parameters: nothing

Return:

  • int <p>The number of characters in $str given the encoding.</p>

lineWrap(int $limit, string $break, bool $add_final_break, string|null $delimiter): static

Line-Wrap the string after $limit, but also after the next word.

EXAMPLE:

Parameters:

  • int $limit [optional] <p>The column width.</p>
  • string $break [optional] <p>The line is broken using the optional break parameter.</p>
  • `bool $add_final_break [optional]

    If this flag is true, then the method will add a $break at the end of the result string.

` - `string|null $delimiter [optional]

You can change the default behavior, where we split the string by newline.

`

Return:

  • static

lineWrapAfterWord(int $limit, string $break, bool $add_final_break, string|null $delimiter): static

Line-Wrap the string after $limit, but also after the next word.

EXAMPLE:

Parameters:

  • int $limit [optional] <p>The column width.</p>
  • string $break [optional] <p>The line is broken using the optional break parameter.</p>
  • `bool $add_final_break [optional]

    If this flag is true, then the method will add a $break at the end of the result string.

` - `string|null $delimiter [optional]

You can change the default behavior, where we split the string by newline.

`

Return:

  • static

lines(): static[]

Splits on newlines and carriage returns, returning an array of Stringy objects corresponding to the lines in the string.

EXAMPLE: s("fòô\r\nbàř\n")->lines(); // ['fòô', 'bàř', '']

Parameters: nothing

Return:

  • static[] <p>An array of Stringy objects.</p>

linesCollection(): CollectionStringy|static[]

Splits on newlines and carriage returns, returning an array of Stringy objects corresponding to the lines in the string.

EXAMPLE:

Parameters: nothing

Return:

  • \CollectionStringy|static[] <p>An collection of Stringy objects.</p>

longestCommonPrefix(string $otherStr): static

Returns the longest common prefix between the string and $otherStr.

EXAMPLE: s('foobar')->longestCommonPrefix('foobaz'); // 'fooba'

Parameters:

  • string $otherStr <p>Second string for comparison.</p>

Return:

  • static <p>Object with its $str being the longest common prefix.</p>

longestCommonSubstring(string $otherStr): static

Returns the longest common substring between the string and $otherStr.

In the case of ties, it returns that which occurs first.

EXAMPLE: s('foobar')->longestCommonSubstring('boofar'); // 'oo'

Parameters:

  • string $otherStr <p>Second string for comparison.</p>

Return:

  • static <p>Object with its $str being the longest common substring.</p>

longestCommonSuffix(string $otherStr): static

Returns the longest common suffix between the string and $otherStr.

EXAMPLE: s('fòôbàř')->longestCommonSuffix('fòrbàř'); // 'bàř'

Parameters:

  • string $otherStr <p>Second string for comparison.</p>

Return:

  • static <p>Object with its $str being the longest common suffix.</p>

lowerCaseFirst(): static

Converts the first character of the string to lower case.

EXAMPLE: s('Σ Foo')->lowerCaseFirst(); // 'σ Foo'

Parameters: nothing

Return:

  • static <p>Object with the first character of $str being lower case.</p>

matchCaseInsensitive(string|\Stringy $str): bool

Determine if the string matches another string regardless of case.

Alias for isEqualsCaseInsensitive()

EXAMPLE:

Parameters:

  • string|\Stringy ...$str <p>The string to compare against.</p>

Return:

  • bool

matchCaseSensitive(string|\Stringy $str): bool

Determine if the string matches another string.

Alias for isEqualsCaseSensitive()

EXAMPLE:

Parameters:

  • string|\Stringy ...$str <p>The string to compare against.</p>

Return:

  • bool

md5(): static

Create a md5 hash from the current string.

Parameters: nothing

Return:

  • static

newLineToHtmlBreak(): static

Replace all breaks [
| \r\n | \r | \n | .

..] into "
".

EXAMPLE:

Parameters: nothing

Return:

  • static

nth(int $step, int $offset): static

Get every nth character of the string.

EXAMPLE:

Parameters:

  • int $step <p>The number of characters to step.</p>
  • int $offset [optional] <p>The string offset to start at.</p>

Return:

  • static

offsetExists(int $offset): bool

Returns whether or not a character exists at an index. Offsets may be negative to count from the last character in the string. Implements part of the ArrayAccess interface.

EXAMPLE:

Parameters:

  • int $offset <p>The index to check.</p>

Return:

  • bool <p>Whether or not the index exists.</p>

offsetGet(int $offset): string

Returns the character at the given index. Offsets may be negative to count from the last character in the string. Implements part of the ArrayAccess interface, and throws an OutOfBoundsException if the index does not exist.

EXAMPLE:

Parameters:

  • int $offset <p>The <strong>index</strong> from which to retrieve the char.</p>

Return:

  • string <p>The character at the specified index.</p>

offsetSet(int $offset, mixed $value): void

Implements part of the ArrayAccess interface, but throws an exception when called. This maintains the immutability of Stringy objects.

EXAMPLE:

Parameters:

  • int $offset <p>The index of the character.</p>
  • mixed $value <p>Value to set.</p>

Return:

  • void

offsetUnset(int $offset): void

Implements part of the ArrayAccess interface, but throws an exception when called. This maintains the immutability of Stringy objects.

EXAMPLE:

Parameters:

  • int $offset <p>The index of the character.</p>

Return:

  • void

pad(int $length, string $padStr, string $padType): static

Pads the string to a given length with $padStr. If length is less than or equal to the length of the string, no padding takes places. The default string used for padding is a space, and the default type (one of 'left', 'right', 'both') is 'right'. Throws an InvalidArgumentException if $padType isn't one of those 3 values.

EXAMPLE: s('fòôbàř')->pad(9, '-/', 'left'); // '-/-fòôbàř'

Parameters:

  • int $length <p>Desired string length after padding.</p>
  • string $padStr [optional] <p>String used to pad, defaults to space. Default: ' '</p>
  • string $padType [optional] <p>One of 'left', 'right', 'both'. Default: 'right'</p>

Return:

  • static <p>Object with a padded $str.</p>

padBoth(int $length, string $padStr): static

Returns a new string of a given length such that both sides of the string are padded. Alias for pad() with a $padType of 'both'.

EXAMPLE: s('foo bar')->padBoth(9, ' '); // ' foo bar '

Parameters:

  • int $length <p>Desired string length after padding.</p>
  • string $padStr [optional] <p>String used to pad, defaults to space. Default: ' '</p>

Return:

  • static <p>String with padding applied.</p>

padLeft(int $length, string $padStr): static

Returns a new string of a given length such that the beginning of the string is padded. Alias for pad() with a $padType of 'left'.

EXAMPLE: s('foo bar')->padLeft(9, ' '); // ' foo bar'

Parameters:

  • int $length <p>Desired string length after padding.</p>
  • string $padStr [optional] <p>String used to pad, defaults to space. Default: ' '</p>

Return:

  • static <p>String with left padding.</p>

padRight(int $length, string $padStr): static

Returns a new string of a given length such that the end of the string is padded. Alias for pad() with a $padType of 'right'.

EXAMPLE: s('foo bar')->padRight(10, '*'); // 'foo bar*_'

Parameters:

  • int $length <p>Desired string length after padding.</p>
  • string $padStr [optional] <p>String used to pad, defaults to space. Default: ' '</p>

Return:

  • static <p>String with right padding.</p>

pascalCase(): static

Convert the string to PascalCase.

Alias for studlyCase()

EXAMPLE:

Parameters: nothing

Return:

  • static

prepend(string $prefix): static

Returns a new string starting with $prefix.

EXAMPLE: s('bàř')->prepend('fòô'); // 'fòôbàř'

Parameters:

  • string ...$prefix <p>The string to append.</p>

Return:

  • static <p>Object with appended $prefix.</p>

prependStringy(\CollectionStringy|static $prefix): static

Returns a new string starting with $prefix.

EXAMPLE:

Parameters:

  • CollectionStringy<int, static>|static ...$prefix <p>The Stringy objects to append.</p>

Return:

  • static <p>Object with appended $prefix.</p>

regexReplace(string $pattern, string $replacement, string $options, string $delimiter): static

Replaces all occurrences of $pattern in $str by $replacement.

EXAMPLE: s('fòô ')->regexReplace('f[òô]+\s', 'bàř'); // 'bàř' s('fò')->regexReplace('(ò)', '\1ô'); // 'fòô'

Parameters:

  • string $pattern <p>The regular expression pattern.</p>
  • string $replacement <p>The string to replace with.</p>
  • string $options [optional] <p>Matching conditions to be used.</p>
  • string $delimiter [optional] <p>Delimiter the the regex. Default: '/'</p>

Return:

  • static <p>Object with the result2ing $str after the replacements.</p>

removeHtml(string $allowableTags): static

Remove html via "strip_tags()" from the string.

EXAMPLE: s('řàb <ô>òf', ô
foo lall')->removeHtml('

'); // 'řàb òf', ô
foo lall'

Parameters:

  • `string $allowableTags [optional]

    You can use the optional second parameter to specify tags which should not be stripped. Default: null

`

Return:

  • static

removeHtmlBreak(string $replacement): static

Remove all breaks [
| \r\n | \r | \n | .

..] from the string.

EXAMPLE: s('řàb <ô>òf', ô
foo lall')->removeHtmlBreak(''); // 'řàb <ô>òf', ô< foo lall'

Parameters:

  • string $replacement [optional] <p>Default is a empty string.</p>

Return:

  • static

removeLeft(string $substring): static

Returns a new string with the prefix $substring removed, if present.

EXAMPLE: s('fòôbàř')->removeLeft('fòô'); // 'bàř'

Parameters:

  • string $substring <p>The prefix to remove.</p>

Return:

  • static <p>Object having a $str without the prefix $substring.</p>

removeRight(string $substring): static

Returns a new string with the suffix $substring removed, if present.

EXAMPLE: s('fòôbàř')->removeRight('bàř'); // 'fòô'

Parameters:

  • string $substring <p>The suffix to remove.</p>

Return:

  • static <p>Object having a $str without the suffix $substring.</p>

removeXss(): static

Try to remove all XSS-attacks from the string.

EXAMPLE: s('')->removeXss(); // ''

Parameters: nothing

Return:

  • static

repeat(int $multiplier): static

Returns a repeated string given a multiplier.

EXAMPLE: s('α')->repeat(3); // 'ααα'

Parameters:

  • int $multiplier <p>The number of times to repeat the string.</p>

Return:

  • static <p>Object with a repeated str.</p>

replace(string $search, string $replacement, bool $caseSensitive): static

Replaces all occurrences of $search in $str by $replacement.

EXAMPLE: s('fòô bàř fòô bàř')->replace('fòô ', ''); // 'bàř bàř'

Parameters:

  • string $search <p>The needle to search for.</p>
  • string $replacement <p>The string to replace with.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • static <p>Object with the resulting $str after the replacements.</p>

replaceAll(string[] $search, string|string[] $replacement, bool $caseSensitive): static

Replaces all occurrences of $search in $str by $replacement.

EXAMPLE: s('fòô bàř lall bàř')->replaceAll(['fòÔ ', 'lall'], '', false); // 'bàř bàř'

Parameters:

  • string[] $search <p>The elements to search for.</p>
  • string|string[] $replacement <p>The string to replace with.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • static <p>Object with the resulting $str after the replacements.</p>

replaceBeginning(string $search, string $replacement): static

Replaces all occurrences of $search from the beginning of string with $replacement.

EXAMPLE: s('fòô bàř fòô bàř')->replaceBeginning('fòô', ''); // ' bàř bàř'

Parameters:

  • string $search <p>The string to search for.</p>
  • string $replacement <p>The replacement.</p>

Return:

  • static <p>Object with the resulting $str after the replacements.</p>

replaceEnding(string $search, string $replacement): static

Replaces all occurrences of $search from the ending of string with $replacement.

EXAMPLE: s('fòô bàř fòô bàř')->replaceEnding('bàř', ''); // 'fòô bàř fòô '

Parameters:

  • string $search <p>The string to search for.</p>
  • string $replacement <p>The replacement.</p>

Return:

  • static <p>Object with the resulting $str after the replacements.</p>

replaceFirst(string $search, string $replacement): static

Replaces first occurrences of $search from the beginning of string with $replacement.

EXAMPLE:

Parameters:

  • string $search <p>The string to search for.</p>
  • string $replacement <p>The replacement.</p>

Return:

  • static <p>Object with the resulting $str after the replacements.</p>

replaceLast(string $search, string $replacement): static

Replaces last occurrences of $search from the ending of string with $replacement.

EXAMPLE:

Parameters:

  • string $search <p>The string to search for.</p>
  • string $replacement <p>The replacement.</p>

Return:

  • static <p>Object with the resulting $str after the replacements.</p>

reverse(): static

Returns a reversed string. A multibyte version of strrev().

EXAMPLE: s('fòôbàř')->reverse(); // 'řàbôòf'

Parameters: nothing

Return:

  • static <p>Object with a reversed $str.</p>

safeTruncate(int $length, string $substring, bool $ignoreDoNotSplitWordsForOneWord): static

Truncates the string to a given length, while ensuring that it does not split words. If $substring is provided, and truncating occurs, the string is further truncated so that the substring may be appended without exceeding the desired length.

EXAMPLE: s('What are your plans today?')->safeTruncate(22, '...'); // 'What are your plans...'

Parameters:

  • int $length <p>Desired length of the truncated string.</p>
  • string $substring [optional] <p>The substring to append if it can fit. Default: ''</p>
  • bool $ignoreDoNotSplitWordsForOneWord

Return:

  • static <p>Object with the resulting $str after truncating.</p>

setInternalEncoding(string $new_encoding): static

Set the internal character encoding.

EXAMPLE:

Parameters:

  • string $new_encoding <p>The desired character encoding.</p>

Return:

  • static

sha1(): static

Create a sha1 hash from the current string.

EXAMPLE:

Parameters: nothing

Return:

  • static

sha256(): static

Create a sha256 hash from the current string.

EXAMPLE:

Parameters: nothing

Return:

  • static

sha512(): static

Create a sha512 hash from the current string.

EXAMPLE:

Parameters: nothing

Return:

  • static

shortenAfterWord(int $length, string $strAddOn): static

Shorten the string after $length, but also after the next word.

EXAMPLE: s('this is a test')->shortenAfterWord(2, '...'); // 'this...'

Parameters:

  • int $length <p>The given length.</p>
  • string $strAddOn [optional] <p>Default: '…'</p>

Return:

  • static

shuffle(): static

A multibyte string shuffle function. It returns a string with its characters in random order.

EXAMPLE: s('fòôbàř')->shuffle(); // 'àôřbòf'

Parameters: nothing

Return:

  • static <p>Object with a shuffled $str.</p>

similarity(string $str): float

Calculate the similarity between two strings.

EXAMPLE:

Parameters:

  • string $str <p>The delimiting string.</p>

Return:

  • float

slice(int $start, int $end): static

Returns the substring beginning at $start, and up to, but not including the index specified by $end. If $end is omitted, the function extracts the remaining string. If $end is negative, it is computed from the end of the string.

EXAMPLE: s('fòôbàř')->slice(3, -1); // 'bà'

Parameters:

  • int $start <p>Initial index from which to begin extraction.</p>
  • int $end [optional] <p>Index at which to end extraction. Default: null</p>

Return:

  • static <p>Object with its $str being the extracted substring.</p>

slugify(string $separator, string $language, string[] $replacements, bool $replace_extra_symbols, bool $use_str_to_lower, bool $use_transliterate): static

Converts the string into an URL slug. This includes replacing non-ASCII characters with their closest ASCII equivalents, removing remaining non-ASCII and non-alphanumeric characters, and replacing whitespace with $separator. The separator defaults to a single dash, and the string is also converted to lowercase. The language of the source string can also be supplied for language-specific transliteration.

EXAMPLE: s('Using strings like fòô bàř')->slugify(); // 'using-strings-like-foo-bar'

Parameters:

  • string $separator [optional] <p>The string used to replace whitespace.</p>
  • string $language [optional] <p>Language of the source string.</p>
  • array<string, string> $replacements [optional] <p>A map of replaceable strings.</p>
  • bool $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>
  • bool $use_str_to_lower [optional] <p>Use "string to lower" for the input.</p>
  • bool $use_transliterate [optional] <p>Use ASCII::to_transliterate() for unknown chars.</p>

Return:

  • static <p>Object whose $str has been converted to an URL slug.</p>

snakeCase(): static

Convert the string to snake_case.

EXAMPLE:

Parameters: nothing

Return:

  • static

snakeize(): static

Convert a string to snake_case.

EXAMPLE: s('foo1 Bar')->snakeize(); // 'foo_1_bar'

Parameters: nothing

Return:

  • static <p>Object with $str in snake_case.</p>

softWrap(int $width, string $break): static

Wrap the string after the first whitespace character after a given number of characters.

EXAMPLE:

Parameters:

  • int $width <p>Number of characters at which to wrap.</p>
  • string $break [optional] <p>Character used to break the string. | Default "\n"</p>

Return:

  • static

split(string $pattern, int $limit): static[]

Splits the string with the provided regular expression, returning an array of Stringy objects. An optional integer $limit will truncate the results.

EXAMPLE: s('foo,bar,baz')->split(',', 2); // ['foo', 'bar']

Parameters:

  • string $pattern <p>The regex with which to split the string.</p>
  • int $limit [optional] <p>Maximum number of results to return. Default: -1 === no limit</p>

Return:

  • static[] <p>An array of Stringy objects.</p>

splitCollection(string $pattern, int $limit): CollectionStringy|static[]

Splits the string with the provided regular expression, returning an collection of Stringy objects. An optional integer $limit will truncate the results.

EXAMPLE:

Parameters:

  • string $pattern <p>The regex with which to split the string.</p>
  • int $limit [optional] <p>Maximum number of results to return. Default: -1 === no limit</p>

Return:

  • \CollectionStringy|static[] <p>An collection of Stringy objects.</p>

startsWith(string $substring, bool $caseSensitive): bool

Returns true if the string begins with $substring, false otherwise. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.

EXAMPLE: s('FÒÔbàřbaz')->startsWith('fòôbàř', false); // true

Parameters:

  • string $substring <p>The substring to look for.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • bool <p>Whether or not $str starts with $substring.</p>

startsWithAny(string[] $substrings, bool $caseSensitive): bool

Returns true if the string begins with any of $substrings, false otherwise.

By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.

EXAMPLE: s('FÒÔbàřbaz')->startsWithAny(['fòô', 'bàř'], false); // true

Parameters:

  • string[] $substrings <p>Substrings to look for.</p>
  • bool $caseSensitive [optional] <p>Whether or not to enforce case-sensitivity. Default: true</p>

Return:

  • bool <p>Whether or not $str starts with $substring.</p>

strip(string|string[] $search): static

Remove one or more strings from the string.

EXAMPLE:

Parameters:

  • string|string[] $search One or more strings to be removed

Return:

  • static

stripWhitespace(): static

Strip all whitespace characters. This includes tabs and newline characters, as well as multibyte whitespace such as the thin space and ideographic space.

EXAMPLE: s(' Ο συγγραφέας ')->stripWhitespace(); // 'Οσυγγραφέας'

Parameters: nothing

Return:

  • static

stripeCssMediaQueries(): static

Remove css media-queries.

EXAMPLE: s('test @media (min-width:660px){ .des-cla #mv-tiles{width:480px} } test ')->stripeCssMediaQueries(); // 'test test '

Parameters: nothing

Return:

  • static

stripeEmptyHtmlTags(): static

Remove empty html-tag.

EXAMPLE: s('foo

bar')->stripeEmptyHtmlTags(); // 'foobar'

Parameters: nothing

Return:

  • static

studlyCase(): static

Convert the string to StudlyCase.

EXAMPLE:

Parameters: nothing

Return:

  • static

substr(int $start, int $length): static

Returns the substring beginning at $start with the specified $length.

It differs from the $this->utf8::substr() function in that providing a $length of null will return the rest of the string, rather than an empty string.

EXAMPLE:

Parameters:

  • int $start <p>Position of the first character to use.</p>
  • int $length [optional] <p>Maximum number of characters used. Default: null</p>

Return:

  • static <p>Object with its $str being the substring.</p>

substring(int $start, int $length): static

Return part of the string.

Alias for substr()

EXAMPLE: s('fòôbàř')->substring(2, 3); // 'ôbà'

Parameters:

  • int $start <p>Starting position of the substring.</p>
  • int $length [optional] <p>Length of substring.</p>

Return:

  • static

substringOf(string $needle, bool $beforeNeedle): static

Gets the substring after (or before via "$beforeNeedle") the first occurrence of the "$needle".

If no match is found returns new empty Stringy object.

EXAMPLE:

Parameters:

  • string $needle <p>The string to look for.</p>
  • bool $beforeNeedle [optional] <p>Default: false</p>

Return:

  • static

substringOfIgnoreCase(string $needle, bool $beforeNeedle): static

Gets the substring after (or before via "$beforeNeedle") the first occurrence of the "$needle".

If no match is found returns new empty Stringy object.

EXAMPLE:

Parameters:

  • string $needle <p>The string to look for.</p>
  • bool $beforeNeedle [optional] <p>Default: false</p>

Return:

  • static

surround(string $substring): static

Surrounds $str with the given substring.

EXAMPLE: s(' ͜ ')->surround('ʘ'); // 'ʘ ͜ ʘ'

Parameters:

  • string $substring <p>The substring to add to both sides.</P>

Return:

  • static <p>Object whose $str had the substring both prepended and appended.</p>

swapCase(): static

Returns a case swapped version of the string.

EXAMPLE: s('Ντανιλ')->swapCase(); // 'νΤΑΝΙΛ'

Parameters: nothing

Return:

  • static <p>Object whose $str has each character's case swapped.</P>

tidy(): static

Returns a string with smart quotes, ellipsis characters, and dashes from Windows-1252 (commonly used in Word documents) replaced by their ASCII equivalents.

EXAMPLE: s('“I see…”')->tidy(); // '"I see..."'

Parameters: nothing

Return:

  • static <p>Object whose $str has those characters removed.</p>

titleize(array|string[]|null $ignore, string|null $word_define_chars, string|null $language): static

Returns a trimmed string with the first letter of each word capitalized.

Also accepts an array, $ignore, allowing you to list words not to be capitalized.

EXAMPLE: $ignore = ['at', 'by', 'for', 'in', 'of', 'on', 'out', 'to', 'the']; s('i like to watch television')->titleize($ignore); // 'I Like to Watch Television'

Parameters:

  • array|string[]|null $ignore [optional] <p>An array of words not to capitalize or null. Default: null</p>
  • string|null $word_define_chars [optional] <p>An string of chars that will be used as whitespace separator === words.</p>
  • string|null $language [optional] <p>Language of the source string.</p>

Return:

  • static <p>Object with a titleized $str.</p>

titleizeForHumans(string[] $ignore): static

Returns a trimmed string in proper title case: Also accepts an array, $ignore, allowing you to list words not to be capitalized.

EXAMPLE:

Adapted from John Gruber's script.

Parameters:

  • string[] $ignore <p>An array of words not to capitalize.</p>

Return:

  • static <p>Object with a titleized $str</p>

toAscii(string $language, bool $removeUnsupported): static

Returns an ASCII version of the string. A set of non-ASCII characters are replaced with their closest ASCII counterparts, and the rest are removed by default. The language or locale of the source string can be supplied for language-specific transliteration in any of the following formats: en, en_GB, or en-GB. For example, passing "de" results in "äöü" mapping to "aeoeue" rather than "aou" as in other languages.

EXAMPLE: s('fòôbàř')->toAscii(); // 'foobar'

Parameters:

  • string $language [optional] <p>Language of the source string.</p>
  • bool $removeUnsupported [optional] <p>Whether or not to remove the unsupported characters.</p>

Return:

  • static <p>Object whose $str contains only ASCII characters.</p>

toBoolean(): bool

Returns a boolean representation of the given logical string value.

For example, 'true', '1', 'on' and 'yes' will return true. 'false', '0', 'off', and 'no' will return false. In all instances, case is ignored. For other numeric strings, their sign will determine the return value. In addition, blank strings consisting of only whitespace will return false. For all other strings, the return value is a result of a boolean cast.

EXAMPLE: s('OFF')->toBoolean(); // false

Parameters: nothing

Return:

  • bool <p>A boolean value for the string.</p>

toLowerCase(bool $tryToKeepStringLength, string|null $lang): static

Converts all characters in the string to lowercase.

EXAMPLE: s('FÒÔBÀŘ')->toLowerCase(); // 'fòôbàř'

Parameters:

  • bool $tryToKeepStringLength [optional] <p>true === try to keep the string length: e.g. ẞ -> ß</p>
  • string|null $lang [optional] <p>Set the language for special cases: az, el, lt, tr</p>

Return:

  • static <p>Object with all characters of $str being lowercase.</p>

toSpaces(int $tabLength): static

Converts each tab in the string to some number of spaces, as defined by $tabLength. By default, each tab is converted to 4 consecutive spaces.

EXAMPLE: s(' String speech = "Hi"')->toSpaces(); // ' String speech = "Hi"'

Parameters:

  • int $tabLength [optional] <p>Number of spaces to replace each tab with. Default: 4</p>

Return:

  • static <p>Object whose $str has had tabs switched to spaces.</p>

toString(): string

Return Stringy object as string, but you can also use (string) for automatically casting the object into a string.

EXAMPLE: s('fòôbàř')->toString(); // 'fòôbàř'

Parameters: nothing

Return:

  • string

toTabs(int $tabLength): static

Converts each occurrence of some consecutive number of spaces, as defined by $tabLength, to a tab. By default, each 4 consecutive spaces are converted to a tab.

EXAMPLE: s(' fòô bàř')->toTabs(); // ' fòô bàř'

Parameters:

  • int $tabLength [optional] <p>Number of spaces to replace with a tab. Default: 4</p>

Return:

  • static <p>Object whose $str has had spaces switched to tabs.</p>

toTitleCase(): static

Converts the first character of each word in the string to uppercase and all other chars to lowercase.

EXAMPLE: s('fòô bàř')->toTitleCase(); // 'Fòô Bàř'

Parameters: nothing

Return:

  • static <p>Object with all characters of $str being title-cased.</p>

toTransliterate(bool $strict, string $unknown): static

Returns an ASCII version of the string. A set of non-ASCII characters are replaced with their closest ASCII counterparts, and the rest are removed unless instructed otherwise.

EXAMPLE:

Parameters:

  • bool $strict [optional] <p>Use "transliterator_transliterate()" from PHP-Intl | WARNING: bad performance | Default: false</p>
  • string $unknown [optional] <p>Character use if character unknown. (default is ?)</p>

Return:

  • static <p>Object whose $str contains only ASCII characters.</p>

toUpperCase(bool $tryToKeepStringLength, string|null $lang): static

Converts all characters in the string to uppercase.

EXAMPLE: s('fòôbàř')->toUpperCase(); // 'FÒÔBÀŘ'

Parameters:

  • bool $tryToKeepStringLength [optional] <p>true === try to keep the string length: e.g. ẞ -> ß</p>
  • string|null $lang [optional] <p>Set the language for special cases: az, el, lt, tr</p>

Return:

  • static <p>Object with all characters of $str being uppercase.</p>

trim(string $chars): static

Returns a string with whitespace removed from the start and end of the string. Supports the removal of unicode whitespace. Accepts an optional string of characters to strip instead of the defaults.

EXAMPLE: s(' fòôbàř ')->trim(); // 'fòôbàř'

Parameters:

  • string $chars [optional] <p>String of characters to strip. Default: null</p>

Return:

  • static <p>Object with a trimmed $str.</p>

trimLeft(string $chars): static

Returns a string with whitespace removed from the start of the string.

Supports the removal of unicode whitespace. Accepts an optional string of characters to strip instead of the defaults.

EXAMPLE: s(' fòôbàř ')->trimLeft(); // 'fòôbàř '

Parameters:

  • string $chars [optional] <p>Optional string of characters to strip. Default: null</p>

Return:

  • static <p>Object with a trimmed $str.</p>

trimRight(string $chars): static

Returns a string with whitespace removed from the end of the string.

Supports the removal of unicode whitespace. Accepts an optional string of characters to strip instead of the defaults.

EXAMPLE: s(' fòôbàř ')->trimRight(); // ' fòôbàř'

Parameters:

  • string $chars [optional] <p>Optional string of characters to strip. Default: null</p>

Return:

  • static <p>Object with a trimmed $str.</p>

truncate(int $length, string $substring): static

Truncates the string to a given length. If $substring is provided, and truncating occurs, the string is further truncated so that the substring may be appended without exceeding the desired length.

EXAMPLE: s('What are your plans today?')->truncate(19, '...'); // 'What are your pl...'

Parameters:

  • int $length <p>Desired length of the truncated string.</p>
  • string $substring [optional] <p>The substring to append if it can fit. Default: ''</p>

Return:

  • static <p>Object with the resulting $str after truncating.</p>

underscored(): static

Returns a lowercase and trimmed string separated by underscores.

Underscores are inserted before uppercase characters (with the exception of the first character of the string), and in place of spaces as well as dashes.

EXAMPLE: s('TestUCase')->underscored(); // 'test_u_case'

Parameters: nothing

Return:

  • static <p>Object with an underscored $str.</p>

upperCamelize(): static

Returns an UpperCamelCase version of the supplied string. It trims surrounding spaces, capitalizes letters following digits, spaces, dashes and underscores, and removes spaces, dashes, underscores.

EXAMPLE: s('Upper Camel-Case')->upperCamelize(); // 'UpperCamelCase'

Parameters: nothing

Return:

  • static <p>Object with $str in UpperCamelCase.</p>

upperCaseFirst(): static

Converts the first character of the supplied string to upper case.

EXAMPLE: s('σ foo')->upperCaseFirst(); // 'Σ foo'

Parameters: nothing

Return:

  • static <p>Object with the first character of $str being upper case.</p>

urlDecode(): static

Simple url-decoding.

e.g: 'test+test' => 'test test'

EXAMPLE:

Parameters: nothing

Return:

  • static

urlDecodeMulti(): static

Multi url-decoding + decode HTML entity + fix urlencoded-win1252-chars.

e.g: 'test+test' => 'test test' 'Düsseldorf' => 'Düsseldorf' 'D%FCsseldorf' => 'Düsseldorf' 'Düsseldorf' => 'Düsseldorf' 'D%26%23xFC%3Bsseldorf' => 'Düsseldorf' 'Düsseldorf' => 'Düsseldorf' 'D%C3%BCsseldorf' => 'Düsseldorf' 'D%C3%83%C2%BCsseldorf' => 'Düsseldorf' 'D%25C3%2583%25C2%25BCsseldorf' => 'Düsseldorf'

EXAMPLE:

Parameters: nothing

Return:

  • static

urlDecodeRaw(): static

Simple url-decoding.

e.g: 'test+test' => 'test+test

EXAMPLE:

Parameters: nothing

Return:

  • static

urlDecodeRawMulti(): static

Multi url-decoding + decode HTML entity + fix urlencoded-win1252-chars.

e.g: 'test+test' => 'test+test' 'Düsseldorf' => 'Düsseldorf' 'D%FCsseldorf' => 'Düsseldorf' 'Düsseldorf' => 'Düsseldorf' 'D%26%23xFC%3Bsseldorf' => 'Düsseldorf' 'Düsseldorf' => 'Düsseldorf' 'D%C3%BCsseldorf' => 'Düsseldorf' 'D%C3%83%C2%BCsseldorf' => 'Düsseldorf' 'D%25C3%2583%25C2%25BCsseldorf' => 'Düsseldorf'

EXAMPLE:

Parameters: nothing

Return:

  • static

urlEncode(): static

Simple url-encoding.

e.g: 'test test' => 'test+test'

EXAMPLE:

Parameters: nothing

Return:

  • static

urlEncodeRaw(): static

Simple url-encoding.

e.g: 'test test' => 'test%20test'

EXAMPLE:

Parameters: nothing

Return:

  • static

urlify(string $separator, string $language, string[] $replacements, bool $strToLower): static

Converts the string into an URL slug. This includes replacing non-ASCII characters with their closest ASCII equivalents, removing remaining non-ASCII and non-alphanumeric characters, and replacing whitespace with $separator. The separator defaults to a single dash, and the string is also converted to lowercase.

EXAMPLE: s('Using strings like fòô bàř - 1$')->urlify(); // 'using-strings-like-foo-bar-1-dollar'

Parameters:

  • string $separator [optional] <p>The string used to replace whitespace. Default: '-'</p>
  • string $language [optional] <p>The language for the url. Default: 'en'</p>
  • array<string, string> $replacements [optional] <p>A map of replaceable strings.</p>
  • bool $strToLower [optional] <p>string to lower. Default: true</p>

Return:

  • static <p>Object whose $str has been converted to an URL slug.</p>

utf8ify(): static

Converts the string into an valid UTF-8 string.

EXAMPLE: s('Düsseldorf')->utf8ify(); // 'Düsseldorf'

Parameters: nothing

Return:

  • static

words(string $char_list, bool $remove_empty_values, int|null $remove_short_values): static[]

Convert a string into an array of words.

EXAMPLE:

Parameters:

  • string $char_list [optional] <p>Additional chars for the definition of "words".</p>
  • bool $remove_empty_values [optional] <p>Remove empty values.</p>
  • int|null $remove_short_values [optional] <p>The min. string length or null to disable</p>

Return:

  • static[]

wordsCollection(string $char_list, bool $remove_empty_values, int|null $remove_short_values): CollectionStringy|static[]

Convert a string into an collection of words.

EXAMPLE: S::create('中文空白 oöäü#s')->wordsCollection('#', true)->toStrings(); // ['中文空白', 'oöäü#s']

Parameters:

  • string $char_list [optional] <p>Additional chars for the definition of "words".</p>
  • bool $remove_empty_values [optional] <p>Remove empty values.</p>
  • int|null $remove_short_values [optional] <p>The min. string length or null to disable</p>

Return:

  • \CollectionStringy|static[] <p>An collection of Stringy objects.</p>

wrap(string $substring): static

Surrounds $str with the given substring.

EXAMPLE:

Parameters:

  • string $substring <p>The substring to add to both sides.</P>

Return:

  • static <p>Object whose $str had the substring both prepended and appended.</p>

Tests

From the project directory, tests can be ran using phpunit

Support

For support and donations please visit Github | Issues | PayPal | Patreon.

For status updates and release announcements please visit Releases | Twitter | Patreon.

For professional support please contact me.

Thanks

  • Thanks to GitHub (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.
  • Thanks to IntelliJ as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
  • Thanks to Travis CI for being the most awesome, easiest continous integration tool out there!
  • Thanks to StyleCI for the simple but powerfull code style check.
  • Thanks to PHPStan && Psalm for relly great Static analysis tools and for discover bugs in the code!

License

Released under the MIT License - see LICENSE.txt for details.

Comments
  • Fatal Error when installing Craft CMS

    Fatal Error when installing Craft CMS

    What is this feature about (expected vs actual behaviour)?

    Running composer install Expected: CMS installs Actual: Fatal error in voku/portable-utf8/src/voku/helper/Bootup.php on line 27 every time

    How can I reproduce it?

    This only seems to have happened to me on one out of two servers, so I can't say for sure. But the method I used was to pull a Craft CMS installation from a git repo, then run composer install to install dependencies. The version of Stringy this is running is 5.1.1

    Does it take minutes, hours or days to fix?

    At least hours, because I haven't fixed it yet

    Any additional information?

    I've been migrating a Craft CMS site to a development server but when I run composer install to install dependencies I get this on the 'Generating optimized autoload files' step:

    Generating optimized autoload files
    Deprecation Notice: Class yii\queue\amqp_interop\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/amqp_interop/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\amqp_interop\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/amqp_interop/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\db\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/db/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\db\InfoAction located in ./vendor/yiisoft/yii2-queue/src/drivers/db/InfoAction.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\db\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/db/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\db\migrations\M161119140200Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/db/migrations/M161119140200Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\db\migrations\M170601155600Priority located in ./vendor/yiisoft/yii2-queue/src/drivers/db/migrations/M170601155600Priority.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\db\migrations\M170509001400Retry located in ./vendor/yiisoft/yii2-queue/src/drivers/db/migrations/M170509001400Retry.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\db\migrations\M170307170300Later located in ./vendor/yiisoft/yii2-queue/src/drivers/db/migrations/M170307170300Later.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\sync\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/sync/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\sqs\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/sqs/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\sqs\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/sqs/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\file\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/file/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\file\InfoAction located in ./vendor/yiisoft/yii2-queue/src/drivers/file/InfoAction.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\file\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/file/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\amqp\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/amqp/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\amqp\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/amqp/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\redis\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/redis/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\redis\InfoAction located in ./vendor/yiisoft/yii2-queue/src/drivers/redis/InfoAction.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\redis\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/redis/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\gearman\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/gearman/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\gearman\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/gearman/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\beanstalk\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/beanstalk/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\beanstalk\InfoAction located in ./vendor/yiisoft/yii2-queue/src/drivers/beanstalk/InfoAction.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class yii\queue\beanstalk\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/beanstalk/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class dolphiq\sitemap\assetbundles\Sitemap\SitemapAsset located in ./vendor/dolphiq/sitemap/src/assetbundles/sitemap/SitemapAsset.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class adigital\cookieconsentbanner\assetbundles\CookieConsentBanner\CookieConsentBannerAsset located in ./vendor/adigital/cookie-consent-banner/src/assetbundles/cookieconsentbanner/CookieConsentBannerAsset.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class Solspace\Freeform\Library\Codepack\Exceptions\CodepackException located in ./vendor/solspace/craft-freeform/src/Library/Codepack/Exceptions/CodePackException.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class Solspace\ExpressForms\utilities\CodePack\Exceptions\CodepackException located in ./vendor/solspace/craft-express-forms/src/utilities/CodePack/Exceptions/CodePackException.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class Solspace\ExpressForms\Services\Widgets located in ./vendor/solspace/craft-express-forms/src/services/Widgets.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    Deprecation Notice: Class HTMLPurifier_Language_en_x_test located in ./vendor/ezyang/htmlpurifier/library/HTMLPurifier/Language/classes/en-x-test.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
    PHP Warning:  Unsupported declare 'strict_types' in /var/www/vhosts/example.co.uk/dev.example.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 3
    
    Warning: Unsupported declare 'strict_types' in /var/www/vhosts/example.co.uk/dev.example.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 3
    PHP Fatal error:  Default value for parameters with a class type hint can only be NULL in /var/www/vhosts/example/dev.example.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 27
    
    Fatal error: Default value for parameters with a class type hint can only be NULL in /var/www/vhosts/example.co.uk/dev.example.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 27
    

    The important line is ovviously the fatal error at the end, which seems to be to do with voku Stringy.

    What I've tried Bumping PHP CLI version 5.5.9 -> 7.3.5 Dropping PHP CLI version 7.3.5 -> 7.2.18 Dropping website PHP version 7.3.5 -> 7.2.18 Purging all references to danielstjules repo from composer.lock (no longer appears in either .lock or .json composer files) The one thing I tried which seemed to work is running composer install --no-plugins --no-scripts (the command they recommend you run when running as root). However, this didn't produce the security key for the installation, and then running ./craft setup/security-key produces the same error:

    PHP Warning:  Unsupported declare 'strict_types' in /var/www/vhosts/tsadvertising.co.uk/dev.jurassicfibre.tsadvertising.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 3
    PHP Fatal error:  Default value for parameters with a class type hint can only be NULL in /var/www/vhosts/tsadvertising.co.uk/dev.jurassicfibre.tsadvertising.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 27
    

    Help please!

    wait for response 
    opened by jcush 6
  • More verbosity

    More verbosity

    What is this feature about (expected vs actual behaviour)?

    The tool is great, but it needs more verbosity to make its use more fluid.

    How can I reproduce it?

    Examples of methods to implement: isEmpty, isNotEmpty, equals, chunk, format, etc.

    Does it take minutes, hours or days to fix?

    days

    Any additional information?

    Method list:

    • after • base64 • base64Decode • base64Encode • bcrypt • before • chunk • count • crc32 • crypt • decrypt • encoding • encrypt • equals • explode • first • format • from • hex • hexEncode • hexDecode • insensitiveMatch • in • isEmpty • isNotEmpty • isNumeric • isPrintable • isPunctuation • isWhitespace • join • kebabCase • matches • md5 • nth • pascalCase • sha1 • sha256 • similarity • strip • studlyCase • substring • to • uppercase • url • words • wrap • wrapHard • wrapSoft

    opened by dimacros 5
  • About regex Extraction string

    About regex Extraction string

    What is this feature about (expected vs actual behaviour)?

    Hello, is there a regex string extraction function? I don't seem to have seen it. If anyone sees it, please give me a link. Thank you

    opened by shenmadouyaowen 4
  • How to pass an array of replacements to make? -- Should I use strtr()?

    How to pass an array of replacements to make? -- Should I use strtr()?

    What's the recommended way to pass an array of replacements to make?

    Should I just use PHP's strtr() or Portable UTF8's strtr() directly?

    Basically, I'm wanting an enhanced version of tidy() to normalize searching "this - plus" to find text like "Thïs & That -- plus more!".

    Example replacements to make (but not quite my code, since tidy() helps a lot already): https://github.com/msaari/relevanssi/blob/4.7.2/lib/common.php#L750

    Code so far:

    $result = s( $orig_string )
    	->utf8ify() // do I need this?
    	->tidy()
    	->stripWhitespace()
    	->replaceAll(
    ...
    	);
    

    I see replaceAll() can take an array, but I'm unsure if it's advisable over strtr's logic of starting with longest string. It looks like replaceAll uses the replacement array in order, and I don't think it takes both the subject and replacement (array key => value).

    Maybe the documentation for replaceAll() could be enhanced or a new method added?

    Thanks for any tips!

    opened by cliffordp 4
  • Move defuse/php-encryption to

    Move defuse/php-encryption to "require-dev" because unused other than Tests

    What is this feature about (expected vs actual behaviour)?

    Can "defuse/php-encryption" be moved to "require-dev"?

    How can I reproduce it?

    • use Defuse\Crypto\Crypto; in https://github.com/voku/Stringy/blob/6.4.0/src/Stringy.php#L7 was added with the original commit that added the package itself: https://github.com/voku/Stringy/commit/10ad6d33e05437446a890b408d362f5392972949
    • But it's not used/called within this file, only within Tests files.
    • So should it be moved to "require-dev", for the sake of composer install --no-dev?

    Does it take minutes, hours or days to fix?

    Minutes?

    Any additional information?

    N/A

    feature_request 
    opened by cliffordp 3
  • Method to pass user callback function?

    Method to pass user callback function?

    What is this feature about (expected vs actual behaviour)?

    How can I reproduce it?

    Does it take minutes, hours or days to fix?

    Any additional information?

    Hello, there is exists method to pass user function, that modify string? For example, in Laravel i have str_plural and class_basename so i could be use it in chain

    s($myClass)
        ->callUserFunc(fn($myClass) => class_basename($myClass))
        ->toLowerCase()
        ->callUserFunc(fn($myClass) => str_plural($myClass));
    

    or

    s($myClass)
        ->callUserFunc('class_basename')
        ->toLowerCase()
        ->callUserFunc('str_plural');
    
    opened by fey 3
  • Proper Vendor Prefixed Namespacing

    Proper Vendor Prefixed Namespacing

    I'm running into issues Ambiguous class resolution warnings from composer since some require your fork and others the older unmaintained version. I could ask there to vendor prefix the lib, but well, it's dead. I do understand the backward compat issues with this though...

    wait for response 
    opened by renzo-s 3
  • Update phpunit/phpunit requirement from ~6.0 || ~7.0 to ^8.0.1

    Update phpunit/phpunit requirement from ~6.0 || ~7.0 to ^8.0.1

    Updates the requirements on phpunit/phpunit to permit the latest version.

    Changelog

    Sourced from phpunit/phpunit's changelog.

    8.0.1 - 2019-02-03

    Fixed

    • Fixed #3509: Process Isolation does not work with phpunit.phar

    [8.0.0] - 2019-02-01

    Changed

    • Implemented #3060: Cleanup PHPUnit\Framework\Constraint\Constraint
    • Implemented #3133: Enable dependency resolution by default
    • Implemented #3236: Define which parts of PHPUnit are covered by the backward compatibility promise
    • Implemented #3244: Enable result cache by default
    • Implemented #3288: The void_return fixer of php-cs-fixer is now in effect
    • Implemented #3439: Improve colorization of TestDox output
    • Implemented #3444: Consider data provider that provides data with duplicate keys to be invalid
    • Implemented #3467: Code location hints for [**requires**](https://github.com/requires) annotations as well as --SKIPIF--, --EXPECT--, --EXPECTF--, --EXPECTREGEX--, and --{SECTION}_EXTERNAL-- sections of PHPT tests
    • Implemented #3481: Improved --help output

    Deprecated

    • Implemented #3332: Deprecate annotation(s) for expecting exceptions
    • Implemented #3338: Deprecate assertions (and helper methods) that operate on (non-public) attributes
    • Implemented #3341: Deprecate optional parameters of assertEquals() and assertNotEquals()
    • Implemented #3369: Deprecate assertInternalType() and assertNotInternalType()
    • Implemented #3388: Deprecate the TestListener interface
    • Implemented #3425: Deprecate optional parameters of assertContains() and assertNotContains() as well as using these methods with string haystacks
    • Implemented #3494: Deprecate assertArraySubset()

    Removed

    • Implemented #2762: Drop support for PHP 7.1
    • Implemented #3123: Remove PHPUnit_Framework_MockObject_MockObject

    [8.0.0]: https://github.com/sebastianbergmann/phpunit/compare/7.5...8.0.0

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Note: This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

    You can always request more updates by clicking Bump now in your Dependabot dashboard.

    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)

    Finally, you can contact us by mentioning @dependabot.


    This change is Reviewable

    dependencies 
    opened by dependabot-preview[bot] 3
  • Update voku/urlify requirement from ~4.1 to ~5.0

    Update voku/urlify requirement from ~4.1 to ~5.0

    Updates the requirements on voku/urlify to permit the latest version.

    Changelog

    Sourced from voku/urlify's changelog.

    v5.0.0 (2019-09-03)

    • use "en" as default language
    • use "Portable ASCII" for much better performance

    v4.1.1 (2019-09-03)

    • optimize regex
    • use "preg_quote" | thanks @​cbj4074
    • fix duplicate code

    v4.1.0 (2019-01-12)

    • fix "maxLength" usage
    • use phpcs fixer
    • add support for "Kazakh" and "Slovak"

    v4.0.0 (2017-12-23)

    • update "Portable UTF8" from v4 -> v5

      -> this is a breaking change without API-changes - but the requirement from "Portable UTF8" has been changed (it no longer requires all polyfills from Symfony)

    v3.0.0 (2017-12-01)

    • drop support for PHP < 7.0
    • use "strict_types"

    v2.3.1 (2017-06-25)

    • fix logic of "add_array_to_separator()"
    • "remove apostrophes which are not used as quotes around a string"

    v2.3.0 (2017-05-22)

    • use "voku/stop-words" for the URLify::$remove_list
    • fix "vietnamese"-language-code ('vn' => 'vi')

    v2.2.0

    • add more languages && update docs
    • add more tests
    ... (truncated)
    Commits
    • b0e8524 [+]: use "Portable ASCII" for much better performance
    • 4961b57 [+]: small fixes + code optimizations
    • 41798b1 Merge branch 'master' of https://github.com/voku/urlify
    • fca0ecc Update README.md
    • See full diff in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Pull request limits (per update run and/or open at any time)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)

    Finally, you can contact us by mentioning @dependabot.


    This change is Reviewable

    dependencies 
    opened by dependabot-preview[bot] 2
  • Consider extracting the ascii stuff to a separate package

    Consider extracting the ascii stuff to a separate package

    It would be wonderful if you could extract the toAscii to a separate packagae, and then depend on it like you do for XSS. I'd like to propose that Laravel 7 uses this package's toAscii, but this package currently has too many other dependencies, so I'd love to be able to only pull in toAscii.

    opened by GrahamCampbell 2
  • Slugify function doesnt replace /

    Slugify function doesnt replace /

    Was using the original danielstjules repo but saw they lack updated support. So plan to use this instead. My question/issue is, when using the slugify function it doesnt replace / with a dash like I want it to. So Im having to install a whole new repo, cocur/slugify. I rather use Stringy for all my needs. So is there a way to add support for this? Example:

    $text = 'Texttile/Machine Learning';
    echo s::create($text)->slugify();
    //Comes out as texttilemachine-learning, want it to come out as texttile-machine-learning
    

    Can you add this additional functionality to the slugify function? Or is there something I can do on my end?

    opened by brightboxtech 2
  • Upgrade to GitHub-native Dependabot

    Upgrade to GitHub-native Dependabot

    Dependabot Preview will be shut down on August 3rd, 2021. In order to keep getting Dependabot updates, please merge this PR and migrate to GitHub-native Dependabot before then.

    Dependabot has been fully integrated into GitHub, so you no longer have to install and manage a separate app. This pull request migrates your configuration from Dependabot.com to a config file, using the new syntax. When merged, we'll swap out dependabot-preview (me) for a new dependabot app, and you'll be all set!

    With this change, you'll now use the Dependabot page in GitHub, rather than the Dependabot dashboard, to monitor your version updates, and you'll configure Dependabot through the new config file rather than a UI.

    If you've got any questions or feedback for us, please let us know by creating an issue in the dependabot/dependabot-core repository.

    Learn more about migrating to GitHub-native Dependabot

    Please note that regular @dependabot commands do not work on this pull request.


    This change is Reviewable

    dependencies 
    opened by dependabot-preview[bot] 4
  • Configure WhiteSource Bolt for GitHub

    Configure WhiteSource Bolt for GitHub

    Welcome to WhiteSource Bolt for GitHub! This is an onboarding PR to help you understand and configure settings before WhiteSource starts scanning your repository for security vulnerabilities.

    :vertical_traffic_light: WhiteSource Bolt for GitHub will start scanning your repository only once you merge this Pull Request. To disable WhiteSource Bolt for GitHub, simply close this Pull Request.


    What to Expect

    This PR contains a '.whitesource' configuration file which can be customized to your needs. If no changes were applied to this file, WhiteSource Bolt for GitHub will use the default configuration.

    Before merging this PR, Make sure the Issues tab is enabled. Once you merge this PR, WhiteSource Bolt for GitHub will scan your repository and create a GitHub Issue for every vulnerability detected in your repository.

    If you do not want a GitHub Issue to be created for each detected vulnerability, you can edit the '.whitesource' file and set the 'minSeverityLevel' parameter to 'NONE'.


    :question: Got questions? Check out WhiteSource Bolt for GitHub docs. If you need any further assistance then you can also request help here.


    This change is Reviewable

    opened by mend-bolt-for-github[bot] 2
Owner
Lars Moelleken
Webdeveloper & Sysadmin | egrep '#php|#js|#html|#css|#sass'
Lars Moelleken
A PHP string manipulation library with multibyte support

A PHP string manipulation library with multibyte support. Compatible with PHP 5.4+, PHP 7+, and HHVM. s('string')->toTitleCase()->ensureRight('y') ==

Daniel St. Jules 2.5k Jan 3, 2023
🉑 Portable UTF-8 library - performance optimized (unicode) string functions for php.

?? Portable UTF-8 Description It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your

Lars Moelleken 474 Dec 22, 2022
🔡 Portable ASCII library - performance optimized (ascii) string functions for php.

?? Portable ASCII Description It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your

Lars Moelleken 380 Jan 6, 2023
ATOMASTIC 14 Mar 12, 2022
Multibyte strings as objects

Opis String Multibyte strings Opis String is a tiny library that allows you to work with multibyte encoded strings in an object-oriented manner. The l

Opis 58 Oct 6, 2022
Text - Simple 1 Class Text Manipulation Library

Text - Simple 1 Class Text Manipulation Library Do you remember PHP's string functions? If not, just wrap you text with Text! It will save a minute on

Kazuyuki Hayashi 51 Nov 16, 2021
PHP library to parse urls from string input

Url highlight - PHP library to parse URLs from string input. Works with complex URLs, edge cases and encoded input. Features: Replace URLs in string b

Volodymyr Stelmakh 77 Sep 16, 2022
A language detection library for PHP. Detects the language from a given text string.

language-detection Build Status Code Coverage Version Total Downloads Minimum PHP Version License This library can detect the language of a given text

Patrick Schur 738 Dec 28, 2022
Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

Motto: "Every business should have a detection script to detect mobile readers." About Mobile Detect is a lightweight PHP class for detecting mobile d

Şerban Ghiţă 10.2k Jan 4, 2023
Converts a string to a slug. Includes integrations for Symfony, Silex, Laravel, Zend Framework 2, Twig, Nette and Latte.

cocur/slugify Converts a string into a slug. Developed by Florian Eckerstorfer in Vienna, Europe with the help of many great contributors. Features Re

Cocur 2.8k Dec 22, 2022
SNIA SSS PTS test suite based on SNIA's Solid State Storage Performance Test Specification for Transcend products

SNIA-SSS-PTS ABSTRACT SNIA SSS PTS describes a solid state storage device-level performance test methodology, test suite and reporting format intended

Transcend Information, Inc. 6 Nov 2, 2022
Library for free use Google Translator. With attempts connecting on failure and array support.

GoogleTranslateForFree Packagist: https://packagist.org/packages/dejurin/php-google-translate-for-free Library for free use Google Translator. With at

Yurii De 122 Dec 23, 2022
👮 A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

Agent A PHP desktop/mobile user agent parser with support for Laravel, based on Mobile Detect with desktop support and additional functionality. Insta

Jens Segers 4.2k Jan 5, 2023
A PHP library for generating universally unique identifiers (UUIDs).

ramsey/uuid A PHP library for generating and working with UUIDs. ramsey/uuid is a PHP library for generating and working with universally unique ident

Ben Ramsey 11.9k Jan 8, 2023
A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

URLify for PHP A fast PHP slug generator and transliteration library, started as a PHP port of URLify.js from the Django project. Handles symbols from

Aband*nthecar 667 Dec 20, 2022
ColorJizz is a PHP library for manipulating and converting colors.

#Getting started: ColorJizz-PHP uses the PSR-0 standards for namespaces, so there should be no trouble using with frameworks like Symfony 2. ###Autolo

Mikeemoo 281 Nov 25, 2022
PHP library to detect and manipulate indentation of strings and files

indentation PHP library to detect and manipulate the indentation of files and strings Installation composer require --dev colinodell/indentation Usage

Colin O'Dell 34 Nov 28, 2022
The Universal Device Detection library will parse any User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model.

DeviceDetector Code Status Description The Universal Device Detection library that parses User Agents and detects devices (desktop, tablet, mobile, tv

Matomo Analytics 2.4k Jan 5, 2023
The Hoa\Ustring library.

Hoa is a modular, extensible and structured set of PHP libraries. Moreover, Hoa aims at being a bridge between industrial and research worlds. Hoa\Ust

Hoa 402 Jan 4, 2023