From 187b451ab984ffc8835fb0df8de159f8d2e476e3 Mon Sep 17 00:00:00 2001 From: "Daniel St. Jules" Date: Mon, 17 Feb 2014 10:42:36 -0500 Subject: [PATCH] Create gh-pages branch via GitHub --- index.html | 21 +++++++++++++++++++++ params.json | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index e6ecdac..4acbd57 100644 --- a/index.html +++ b/index.html @@ -56,6 +56,7 @@ Compatible with PHP 5.3+. Inspired by underscore.string.js.

  • ensureLeft
  • ensureRight
  • first
  • +
  • getEncoding
  • humanize
  • insert
  • isAlpha
  • @@ -102,6 +103,7 @@ Compatible with PHP 5.3+. Inspired by underscore.string.js.

  • upperCaseFirst
  • +
  • Links
  • Tests
  • License
  • @@ -372,6 +374,16 @@ setting $caseSensitive to false.

    S::first('fòô bàř', 3, 'UTF-8'); // 'fòô' +

    +getEncoding

    + +

    $stringy->getEncoding()

    + +

    Returns the encoding used by the Stringy object.

    + +
    S::create('fòô bàř', 'UTF-8')->getEncoding();  // 'UTF-8'
    +
    +

    humanize

    @@ -987,6 +999,15 @@ and underscores, and removes spaces, dashes, underscores.

    +Links

    + +

    The following is a list of libraries that extend Stringy:

    + +

    Tests

    From the project directory, tests can be ran using phpunit

    diff --git a/params.json b/params.json index ab0b3b1..3fbee0f 100644 --- a/params.json +++ b/params.json @@ -1 +1 @@ -{"name":"Stringy","tagline":"A PHP string manipulation library with multibyte support","body":"![Stringy](http://danielstjules.com/stringy/logo.png)\r\n\r\nA PHP library with a variety of string manipulation functions with multibyte\r\nsupport. Offers both OO method chaining and a procedural-style static wrapper.\r\nCompatible with PHP 5.3+. Inspired by underscore.string.js.\r\n\r\n[![Build Status](https://travis-ci.org/danielstjules/Stringy.png)](https://travis-ci.org/danielstjules/Stringy)\r\n\r\n* [Requiring/Loading](#requiringloading)\r\n* [OO and Procedural](#oo-and-procedural)\r\n* [Implemented Interfaces](#implemented-interfaces)\r\n* [Methods](#methods)\r\n * [at](#at)\r\n * [camelize](#camelize)\r\n * [chars](#chars)\r\n * [collapseWhitespace](#collapsewhitespace)\r\n * [contains](#contains)\r\n * [countSubstr](#countsubstr)\r\n * [create](#create)\r\n * [dasherize](#dasherize)\r\n * [endsWith](#endswith)\r\n * [ensureLeft](#ensureleft)\r\n * [ensureRight](#ensureright)\r\n * [first](#first)\r\n * [humanize](#humanize)\r\n * [insert](#insert)\r\n * [isAlpha](#isalpha)\r\n * [isAlphanumeric](#isalphanumeric)\r\n * [isBlank](#isblank)\r\n * [isHexadecimal](#ishexadecimal)\r\n * [isJson](#isjson)\r\n * [isLowerCase](#islowercase)\r\n * [isSerialized](#isserialized)\r\n * [isUpperCase](#isuppercase)\r\n * [last](#last)\r\n * [length](#length)\r\n * [longestCommonPrefix](#longestcommonprefix)\r\n * [longestCommonSuffix](#longestcommonsuffix)\r\n * [longestCommonSubstring](#longestcommonsubstring)\r\n * [lowerCaseFirst](#lowercasefirst)\r\n * [pad](#pad)\r\n * [padBoth](#padboth)\r\n * [padLeft](#padleft)\r\n * [padRight](#padright)\r\n * [regexReplace](#regexreplace)\r\n * [removeLeft](#removeleft)\r\n * [removeRight](#removeright)\r\n * [replace](#replace)\r\n * [reverse](#reverse)\r\n * [safeTruncate](#safetruncate)\r\n * [shuffle](#shuffle)\r\n * [slugify](#slugify)\r\n * [startsWith](#startswith)\r\n * [substr](#substr)\r\n * [surround](#surround)\r\n * [swapCase](#swapcase)\r\n * [tidy](#tidy)\r\n * [titleize](#titleize)\r\n * [toAscii](#toascii)\r\n * [toLowerCase](#tolowercase)\r\n * [toSpaces](#tospaces)\r\n * [toTabs](#totabs)\r\n * [toUpperCase](#touppercase)\r\n * [trim](#trim)\r\n * [truncate](#truncate)\r\n * [underscored](#underscored)\r\n * [upperCamelize](#uppercamelize)\r\n * [upperCaseFirst](#uppercasefirst)\r\n* [Tests](#tests)\r\n* [License](#license)\r\n\r\n## Requiring/Loading\r\n\r\nIf you're using Composer to manage dependencies, you can include the following\r\nin your composer.json file:\r\n\r\n \"require\": {\r\n \"danielstjules/stringy\": \"dev-master\"\r\n }\r\n\r\nThen, after running `composer update` or `php composer.phar update`, you can\r\nload the class using Composer's autoloading:\r\n\r\n```php\r\nrequire 'vendor/autoload.php';\r\n```\r\n\r\nOtherwise, you can simply require the file directly:\r\n\r\n```php\r\nrequire_once 'path/to/Stringy/src/Stringy.php';\r\n// or\r\nrequire_once 'path/to/Stringy/src/StaticStringy.php';\r\n```\r\n\r\nAnd in either case, I'd suggest using an alias.\r\n\r\n```php\r\nuse Stringy\\Stringy as S;\r\n// or\r\nuse Stringy\\StaticStringy as S;\r\n```\r\n\r\n## OO and Procedural\r\n\r\nThe library offers both OO method chaining with `Stringy\\Stringy`, as well as\r\nprocedural-style static method calls with `Stringy\\StaticStringy`. An example\r\nof the former is the following:\r\n\r\n```php\r\nuse Stringy\\Stringy as S;\r\necho S::create('Fòô Bàř', 'UTF-8')->collapseWhitespace()->swapCase(); // 'fÒÔ bÀŘ'\r\n```\r\n\r\n`Stringy\\Stringy` has a __toString() method, which returns the current string\r\nwhen the object is used in a string context, ie:\r\n`(string) S::create('foo') // 'foo'`\r\n\r\nUsing the static wrapper, an alternative is the following:\r\n\r\n```php\r\nuse Stringy\\StaticStringy as S;\r\n$string = S::collapseWhitespace('Fòô Bàř', 'UTF-8');\r\necho S::swapCase($string, 'UTF-8'); // 'fÒÔ bÀŘ'\r\n```\r\n\r\n## Implemented Interfaces\r\n\r\n`Stringy\\Stringy` implements the `IteratorAggregate` interface, meaning that\r\n`foreach` can be used with an instance of the class:\r\n\r\n``` php\r\n$stringy = S::create('Fòô Bàř', 'UTF-8');\r\nforeach ($stringy as $char) {\r\n echo $char;\r\n}\r\n// 'Fòô Bàř'\r\n```\r\n\r\nIt implements the `Countable` interface, enabling the use of `count()` to\r\nretrieve the number of characters in the string:\r\n\r\n``` php\r\n$stringy = S::create('Fòô', 'UTF-8');\r\ncount($stringy); // 3\r\n```\r\n\r\nFurthermore, the `ArrayAccess` interface has been implemented. As a result,\r\n`isset()` can be used to check if a character at a specific index exists. And\r\nsince `Stringy\\Stringy` is immutable, any call to `offsetSet` or `offsetUnset`\r\nwill throw an exception. `offsetGet` has been implemented, however, and accepts\r\nboth positive and negative indexes. Invalid indexes result in an\r\n`OutOfBoundsException`.\r\n\r\n``` php\r\n$stringy = S::create('Bàř', 'UTF-8');\r\necho $stringy[2]; // 'ř'\r\necho $stringy[-2]; // 'à'\r\nisset($stringy[-4]); // false\r\n\r\n$stringy[3]; // OutOfBoundsException\r\n$stringy[2] = 'a'; // Exception\r\n```\r\n\r\n## Methods\r\n\r\nIn the list below, any static method other than S::create refers to a method in\r\n`Stringy\\StaticStringy`. For all others, they're found in `Stringy\\Stringy`.\r\nFurthermore, all methods that return a Stringy object or string do not modify\r\nthe original. Stringy objects are immutable.\r\n\r\n*Note: If `$encoding` is not given, it defaults to `mb_internal_encoding()`.*\r\n\r\n#### at\r\n\r\n$stringy->at(int $index)\r\n\r\nS::at(int $index [, string $encoding ])\r\n\r\nReturns the character at $index, with indexes starting at 0.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->at(6);\r\nS::at('fòô bàř', 6, 'UTF-8'); // 'ř'\r\n```\r\n\r\n#### camelize\r\n\r\n$stringy->camelize();\r\n\r\nS::camelize(string $str [, string $encoding ])\r\n\r\nReturns a camelCase version of the string. Trims surrounding spaces,\r\ncapitalizes letters following digits, spaces, dashes and underscores,\r\nand removes spaces, dashes, as well as underscores.\r\n\r\n```php\r\nS::create('Camel-Case')->camelize();\r\nS::camelize('Camel-Case'); // 'camelCase'\r\n```\r\n\r\n#### chars\r\n\r\n$stringy->chars();\r\n\r\nS::chars(string $str [, string $encoding ])\r\n\r\nReturns an array consisting of the characters in the string.\r\n\r\n```php\r\nS::create('Fòô Bàř', 'UTF-8')->chars();\r\nS::chars('Fòô Bàř', 'UTF-8'); // array(F', 'ò', 'ô', ' ', 'B', 'à', 'ř')\r\n```\r\n\r\n#### collapseWhitespace\r\n\r\n$stringy->collapseWhitespace()\r\n\r\nS::collapseWhitespace(string $str [, string $encoding ])\r\n\r\nTrims the string and replaces consecutive whitespace characters with a\r\nsingle space. This includes tabs and newline characters, as well as\r\nmultibyte whitespace such as the thin space and ideographic space.\r\n\r\n```php\r\nS::create(' Ο συγγραφέας ')->collapseWhitespace();\r\nS::collapseWhitespace(' Ο συγγραφέας '); // 'Ο συγγραφέας'\r\n```\r\n\r\n#### contains\r\n\r\n$stringy->contains(string $needle [, boolean $caseSensitive = true ])\r\n\r\nS::contains(string $haystack, string $needle [, boolean $caseSensitive = true [, string $encoding ]])\r\n\r\nReturns true if the string contains $needle, false otherwise. By default,\r\nthe comparison is case-sensitive, but can be made insensitive\r\nby setting $caseSensitive to false.\r\n\r\n```php\r\nS::create('Ο συγγραφέας είπε', 'UTF-8')->contains('συγγραφέας');\r\nS::contains('Ο συγγραφέας είπε', 'συγγραφέας', 'UTF-8'); // true\r\n```\r\n\r\n#### countSubstr\r\n\r\n$stringy->countSubstr(string $substring [, boolean $caseSensitive = true ])\r\n\r\nS::countSubstr(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])\r\n\r\nReturns the number of occurrences of $substring in the given string.\r\nBy default, the comparison is case-sensitive, but can be made insensitive\r\nby setting $caseSensitive to false.\r\n\r\n```php\r\nS::create('Ο συγγραφέας είπε', 'UTF-8')->countSubstr('α');\r\nS::countSubstr('Ο συγγραφέας είπε', 'α', 'UTF-8'); // 2\r\n```\r\n\r\n#### create\r\n\r\nS::create(mixed $str, [, $encoding ])\r\n\r\nCreates a Stringy object and assigns both str and encoding properties\r\nthe supplied values. $str is cast to a string prior to assignment, and if\r\n$encoding is not specified, it defaults to mb_internal_encoding(). It\r\nthen returns the initialized object. Throws an InvalidArgumentException\r\nif the first argument is an array or object without a __toString method.\r\n\r\n```php\r\n$stringy = S::create('fòô bàř', 'UTF-8'); // 'fòô bàř'\r\n```\r\n\r\n#### dasherize\r\n\r\n$stringy->dasherize();\r\n\r\nS::dasherize(string $str [, string $encoding ])\r\n\r\nReturns a lowercase and trimmed string separated by dashes. Dashes are\r\ninserted before uppercase characters (with the exception of the first\r\ncharacter of the string), and in place of spaces as well as underscores.\r\n\r\n```php\r\nS::create('TestDCase')->dasherize();\r\nS::dasherize('TestDCase'); // 'test-d-case'\r\n```\r\n\r\n#### endsWith\r\n\r\n$stringy->endsWith(string $substring [, boolean $caseSensitive = true ])\r\n\r\nS::endsWith(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])\r\n\r\nReturns true if the string ends with $substring, false otherwise. By\r\ndefault, the comparison is case-sensitive, but can be made insensitive by\r\nsetting $caseSensitive to false.\r\n\r\n```php\r\nS::create('FÒÔ bàřs', 'UTF-8')->endsWith('àřs', true);\r\nS::endsWith('FÒÔ bàřs', 'àřs', true, 'UTF-8'); // true\r\n```\r\n\r\n#### ensureLeft\r\n\r\n$stringy->ensureLeft(string $substring)\r\n\r\nS::ensureLeft(string $substring [, string $encoding ])\r\n\r\nEnsures that the string begins with $substring. If it doesn't, it's prepended.\r\n\r\n```php\r\nS::create('foobar')->ensureLeft('http://');\r\nS::ensureLeft('foobar', 'http://'); // 'http://foobar'\r\n```\r\n\r\n#### ensureRight\r\n\r\n$stringy->ensureRight(string $substring)\r\n\r\nS::ensureRight(string $substring [, string $encoding ])\r\n\r\nEnsures that the string begins with $substring. If it doesn't, it's appended.\r\n\r\n```php\r\nS::create('foobar')->ensureRight('.com');\r\nS::ensureRight('foobar', '.com'); // 'foobar.com'\r\n```\r\n\r\n#### first\r\n\r\n$stringy->first(int $n)\r\n\r\nS::first(int $n [, string $encoding ])\r\n\r\nReturns the first $n characters of the string.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->first(3);\r\nS::first('fòô bàř', 3, 'UTF-8'); // 'fòô'\r\n```\r\n\r\n#### humanize\r\n\r\n$stringy->humanize()\r\n\r\nS::humanize(string $str [, string $encoding ])\r\n\r\nCapitalizes the first word of the string, replaces underscores with\r\nspaces, and strips '_id'.\r\n\r\n```php\r\nS::create('author_id')->humanize();\r\nS::humanize('author_id'); // 'Author'\r\n```\r\n\r\n#### insert\r\n\r\n$stringy->insert(int $index, string $substring)\r\n\r\nS::insert(string $str, int $index, string $substring [, string $encoding ])\r\n\r\nInserts $substring into the string at the $index provided.\r\n\r\n```php\r\nS::create('fòô bà', 'UTF-8')->insert('ř', 6);\r\nS::insert('fòô bà', 'ř', 6, 'UTF-8'); // 'fòô bàř'\r\n```\r\n\r\n#### isAlpha\r\n\r\n$stringy->isAlpha()\r\n\r\nS::isAlpha(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only alphabetic chars, false otherwise.\r\n\r\n```php\r\nS::create('丹尼爾', 'UTF-8')->isAlpha();\r\nS::isAlpha('丹尼爾', 'UTF-8'); // true\r\n```\r\n\r\n#### isAlphanumeric\r\n\r\n$stringy->isAlphanumeric()\r\n\r\nS::isAlphanumeric(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only alphabetic and numeric chars, false\r\notherwise.\r\n\r\n```php\r\nS::create('دانيال1', 'UTF-8')->isAlphanumeric();\r\nS::isAlphanumeric('دانيال1', 'UTF-8'); // true\r\n```\r\n\r\n#### isBlank\r\n\r\n$stringy->isBlank()\r\n\r\nS::isBlank(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only whitespace chars, false otherwise.\r\n\r\n```php\r\nS::create(\"\\n\\t \\v\\f\")->isBlank();\r\nS::isBlank(\"\\n\\t \\v\\f\"); // true\r\n```\r\n\r\n#### isHexadecimal\r\n\r\n$stringy->isHexadecimal()\r\n\r\nS::isHexadecimal(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only hexadecimal chars, false otherwise.\r\n\r\n```php\r\nS::create('A102F')->isHexadecimal();\r\nS::isHexadecimal('A102F'); // true\r\n```\r\n\r\n#### isJson\r\n\r\n$stringy->isJson()\r\n\r\nS::isJson(string $str [, string $encoding ])\r\n\r\nReturns true if the string is JSON, false otherwise.\r\n\r\n```php\r\nS::create('{\"foo\":\"bar\"}')->isJson();\r\nS::isJson('{\"foo\":\"bar\"}'); // true\r\n```\r\n\r\n#### isLowerCase\r\n\r\n$stringy->isLowerCase()\r\n\r\nS::isLowerCase(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only lower case chars, false otherwise.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->isLowerCase();\r\nS::isLowerCase('fòô bàř', 'UTF-8'); // true\r\n```\r\n\r\n#### isSerialized\r\n\r\n$stringy->isSerialized()\r\n\r\nS::isSerialized(string $str [, string $encoding ])\r\n\r\nReturns true if the string is serialized, false otherwise.\r\n\r\n```php\r\nS::create('a:1:{s:3:\"foo\";s:3:\"bar\";}', 'UTF-8')->isSerialized();\r\nS::isSerialized('a:1:{s:3:\"foo\";s:3:\"bar\";}', 'UTF-8'); // true\r\n```\r\n\r\n#### isUpperCase\r\n\r\n$stringy->isUpperCase()\r\n\r\nS::isUpperCase(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only upper case chars, false otherwise.\r\n\r\n```php\r\nS::create('FÒÔBÀŘ', 'UTF-8')->isUpperCase();\r\nS::isUpperCase('FÒÔBÀŘ', 'UTF-8'); // true\r\n```\r\n\r\n#### last\r\n\r\n$stringy->last(int $n)\r\n\r\nS::last(int $n [, string $encoding ])\r\n\r\nReturns the last $n characters of the string.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->last(3);\r\nS::last('fòô bàř', 3, 'UTF-8'); // 'bàř'\r\n```\r\n\r\n#### length\r\n\r\n$stringy->length()\r\n\r\nS::length(string $str [, string $encoding ])\r\n\r\nReturns the length of the string. An alias for PHP's mb_strlen() function.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->length();\r\nS::length('fòô bàř', 'UTF-8'); // 7\r\n```\r\n\r\n#### longestCommonPrefix\r\n\r\n$stringy->longestCommonPrefix(string $otherStr)\r\n\r\nS::longestCommonPrefix(string $str, string $otherStr [, $encoding ])\r\n\r\nReturns the longest common prefix between the string and $otherStr.\r\n\r\n```php\r\nS::create('fòô bar', 'UTF-8')->longestCommonPrefix('fòr bar');\r\nS::longestCommonPrefix('fòô bar', 'fòr bar', 'UTF-8'); // 'fò'\r\n```\r\n\r\n#### longestCommonSuffix\r\n\r\n$stringy->longestCommonSuffix(string $otherStr)\r\n\r\nS::longestCommonSuffix(string $str, string $otherStr [, $encoding ])\r\n\r\nReturns the longest common suffix between the string and $otherStr.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->longestCommonSuffix('fòr bàř');\r\nS::longestCommonSuffix('fòô bàř', 'fòr bàř', 'UTF-8'); // ' bàř'\r\n```\r\n\r\n#### longestCommonSubstring\r\n\r\n$stringy->longestCommonSubstring(string $otherStr)\r\n\r\nS::longestCommonSubstring(string $str, string $otherStr [, $encoding ])\r\n\r\nReturns the longest common substring between the string and $otherStr. In the\r\ncase of ties, it returns that which occurs first.\r\n\r\n```php\r\nS::create('foo bar')->longestCommonSubstring('boo far');\r\nS::longestCommonSubstring('foo bar', 'boo far'); // 'oo '\r\n```\r\n\r\n#### lowerCaseFirst\r\n\r\n$stringy->lowerCaseFirst();\r\n\r\nS::lowerCaseFirst(string $str [, string $encoding ])\r\n\r\nConverts the first character of the supplied string to lower case.\r\n\r\n```php\r\nS::create('Σ test', 'UTF-8')->lowerCaseFirst();\r\nS::lowerCaseFirst('Σ test', 'UTF-8'); // 'σ test'\r\n```\r\n\r\n#### pad\r\n\r\n$stringy->pad(int $length [, string $padStr = ' ' [, string $padType = 'right' ]])\r\n\r\nS::pad(string $str , int $length [, string $padStr = ' ' [, string $padType = 'right' [, string $encoding ]]])\r\n\r\nPads the string to a given length with $padStr. If length is less than\r\nor equal to the length of the string, no padding takes places. The default\r\nstring used for padding is a space, and the default type (one of 'left',\r\n'right', 'both') is 'right'. Throws an InvalidArgumentException if\r\n$padType isn't one of those 3 values.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->pad( 10, '¬ø', 'left');\r\nS::pad('fòô bàř', 10, '¬ø', 'left', 'UTF-8'); // '¬ø¬fòô bàř'\r\n```\r\n\r\n#### padBoth\r\n\r\n$stringy->padBoth(int $length [, string $padStr = ' ' ])\r\n\r\nS::padBoth(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])\r\n\r\nReturns a new string of a given length such that both sides of the string\r\nstring are padded. Alias for pad() with a $padType of 'both'.\r\n\r\n```php\r\nS::create('foo bar')->padBoth(9, ' ');\r\nS::padBoth('foo bar', 9, ' '); // ' foo bar '\r\n```\r\n\r\n#### padLeft\r\n\r\n$stringy->padLeft(int $length [, string $padStr = ' ' ])\r\n\r\nS::padLeft(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])\r\n\r\nReturns a new string of a given length such that the beginning of the\r\nstring is padded. Alias for pad() with a $padType of 'left'.\r\n\r\n```php\r\nS::create($str, $encoding)->padLeft($length, $padStr);\r\nS::padLeft('foo bar', 9, ' '); // ' foo bar'\r\n```\r\n\r\n#### padRight\r\n\r\n$stringy->padRight(int $length [, string $padStr = ' ' ])\r\n\r\nS::padRight(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])\r\n\r\nReturns a new string of a given length such that the end of the string is\r\npadded. Alias for pad() with a $padType of 'right'.\r\n\r\n```php\r\nS::create('foo bar')->padRight(10, '_*');\r\nS::padRight('foo bar', 10, '_*'); // 'foo bar_*_'\r\n```\r\n\r\n#### regexReplace\r\n\r\n$stringy->regexReplace(string $pattern, string $replacement [, string $options = 'msr'])\r\n\r\nS::regexReplace(string $str, string $pattern, string $replacement [, string $options = 'msr' [, string $encoding ]])\r\n\r\nReplaces all occurrences of $pattern in $str by $replacement. An alias\r\nfor mb_ereg_replace(). Note that the 'i' option with multibyte patterns\r\nin mb_ereg_replace() requires PHP 5.4+. This is due to a lack of support\r\nin the bundled version of Oniguruma in PHP 5.3.\r\n\r\n```php\r\nS::create('fòô ', 'UTF-8')->regexReplace('f[òô]+\\s', 'bàř', 'msr');\r\nS::regexReplace('fòô ', 'f[òô]+\\s', 'bàř', 'msr', 'UTF-8'); // 'bàř'\r\n```\r\n\r\n#### removeLeft\r\n\r\n$stringy->removeLeft(string $substring)\r\n\r\nS::removeLeft(string $str, string $substring [, string $encoding ])\r\n\r\nReturns a new string with the prefix $substring removed, if present.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->removeLeft('fòô ');\r\nS::removeLeft('fòô bàř', 'fòô ', 'UTF-8'); // 'bàř'\r\n```\r\n\r\n#### removeRight\r\n\r\n$stringy->removeRight(string $substring)\r\n\r\nS::removeRight(string $str, string $substring [, string $encoding ])\r\n\r\nReturns a new string with the suffix $substring removed, if present.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->removeRight(' bàř');\r\nS::removeRight('fòô bàř', ' bàř', 'UTF-8'); // 'fòô'\r\n```\r\n\r\n#### replace\r\n\r\n$stringy->replace(string $search, string $replacement)\r\n\r\nS::replace(string $str, string $search, string $replacement [, string $encoding ])\r\n\r\nReplaces all occurrences of $search in $str by $replacement.\r\n\r\n```php\r\nS::create('fòô bàř fòô bàř', 'UTF-8')->replace('fòô ', '');\r\nS::replace('fòô bàř fòô bàř', 'fòô ', '', 'UTF-8'); // 'bàř bàř'\r\n```\r\n\r\n#### reverse\r\n\r\n$stringy->reverse()\r\n\r\nS::reverse(string $str, [, string $encoding ])\r\n\r\nReturns a reversed string. A multibyte version of strrev().\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->reverse();\r\nS::reverse('fòô bàř', 'UTF-8'); // 'řàb ôòf'\r\n```\r\n\r\n#### safeTruncate\r\n\r\n$stringy->safeTruncate(int $length, [, string $substring = '' ])\r\n\r\nS::safeTruncate(string $str, int $length, [, string $substring = '' [, string $encoding ]])\r\n\r\nTruncates the string to a given length, while ensuring that it does not\r\nsplit words. If $substring is provided, and truncating occurs, the\r\nstring is further truncated so that the substring may be appended without\r\nexceeding the desired length.\r\n\r\n```php\r\nS::create('What are your plans today?')->safeTruncate(22, '...');\r\nS::safeTruncate('What are your plans today?', 22, '...'); // 'What are your plans...'\r\n```\r\n\r\n#### shuffle\r\n\r\n$stringy->shuffle()\r\n\r\nS::shuffle(string $str [, string $encoding ])\r\n\r\nA multibyte str_shuffle() function. It returns a string with its characters in\r\nrandom order.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->shuffle();\r\nS::shuffle('fòô bàř', 'UTF-8'); // 'àôřb òf'\r\n```\r\n\r\n#### slugify\r\n\r\n$stringy->slugify([ string $replacement = '-' ])\r\n\r\nS::slugify(string $str [, string $replacement = '-' ])\r\n\r\nConverts the string into an URL slug. This includes replacing non-ASCII\r\ncharacters with their closest ASCII equivalents, removing remaining\r\nnon-ASCII and non-alphanumeric characters, and replacing whitespace with\r\n$replacement. The replacement defaults to a single dash, and the string\r\nis also converted to lowercase.\r\n\r\n```php\r\nS::create('Using strings like fòô bàř')->slugify();\r\nS::slugify('Using strings like fòô bàř'); // 'using-strings-like-foo-bar'\r\n```\r\n\r\n#### startsWith\r\n\r\n$stringy->startsWith(string $substring [, boolean $caseSensitive = true ])\r\n\r\nS::startsWith(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])\r\n\r\nReturns true if the string begins with $substring, false otherwise.\r\nBy default, the comparison is case-sensitive, but can be made insensitive\r\nby setting $caseSensitive to false.\r\n\r\n```php\r\nS::create('FÒÔ bàřs', 'UTF-8')->startsWith('fòô bàř', false);\r\nS::startsWith('FÒÔ bàřs', 'fòô bàř', false, 'UTF-8'); // true\r\n```\r\n\r\n#### substr\r\n\r\n$stringy->substr(int $start [, int $length ])\r\n\r\nS::substr(string $str, int $start [, int $length [, string $encoding ]])\r\n\r\nReturns the substring beginning at $start with the specified $length.\r\nIt differs from the mb_substr() function in that providing a $length of\r\nnull will return the rest of the string, rather than an empty string.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->substr(2, 3);\r\nS::substr('fòô bàř', 2, 3, 'UTF-8'); // 'ô b'\r\n```\r\n\r\n#### surround\r\n\r\n$stringy->surround(string $substring)\r\n\r\nS::surround(string $str, string $substring)\r\n\r\nSurrounds a string with the given substring.\r\n\r\n```php\r\nS::create(' ͜ ')->surround('ʘ');\r\nS::surround(' ͜ ', 'ʘ'); // 'ʘ ͜ ʘ'\r\n```\r\n\r\n#### swapCase\r\n\r\n$stringy->swapCase();\r\n\r\nS::swapCase(string $str [, string $encoding ])\r\n\r\nReturns a case swapped version of the string.\r\n\r\n```php\r\nS::create('Ντανιλ', 'UTF-8')->swapCase();\r\nS::swapCase('Ντανιλ', 'UTF-8'); // 'νΤΑΝΙΛ'\r\n```\r\n\r\n#### tidy\r\n\r\n$stringy->tidy()\r\n\r\nS::tidy(string $str)\r\n\r\nReturns a string with smart quotes, ellipsis characters, and dashes from\r\nWindows-1252 (commonly used in Word documents) replaced by their ASCII equivalents.\r\n\r\n```php\r\nS::create('“I see…”')->tidy();\r\nS::tidy('“I see…”'); // '\"I see...\"'\r\n```\r\n\r\n#### titleize\r\n\r\n$stringy->titleize([ string $encoding ])\r\n\r\nS::titleize(string $str [, array $ignore [, string $encoding ]])\r\n\r\nReturns a trimmed string with the first letter of each word capitalized.\r\nIgnores the case of other letters, preserving any acronyms. Also accepts\r\nan array, $ignore, allowing you to list words not to be capitalized.\r\n\r\n```php\r\n$ignore = array('at', 'by', 'for', 'in', 'of', 'on', 'out', 'to', 'the');\r\nS::create('i like to watch DVDs at home', 'UTF-8')->titleize($ignore);\r\nS::titleize('i like to watch DVDs at home', $ignore, 'UTF-8');\r\n// 'I Like to Watch DVDs at Home'\r\n```\r\n\r\n#### toAscii\r\n\r\n$stringy->toAscii()\r\n\r\nS::toAscii(string $str)\r\n\r\nReturns an ASCII version of the string. A set of non-ASCII characters are\r\nreplaced with their closest ASCII counterparts, and the rest are removed.\r\n\r\n```php\r\nS::create('fòô bàř')->toAscii();\r\nS::toAscii('fòô bàř'); // 'foo bar'\r\n```\r\n\r\n#### toLowerCase\r\n\r\n$stringy->toLowerCase()\r\n\r\nS::toLowerCase(string $str [, string $encoding ])\r\n\r\nConverts all characters in the string to lowercase. An alias for PHP's\r\nmb_strtolower().\r\n\r\n```php\r\nS::create('FÒÔ BÀŘ', 'UTF-8')->toLowerCase();\r\nS::toLowerCase('FÒÔ BÀŘ', 'UTF-8'); // 'fòô bàř'\r\n```\r\n\r\n#### toSpaces\r\n\r\n$stringy->toSpaces([ tabLength = 4 ])\r\n\r\nS::toSpaces(string $str, [, int $tabLength = 4 ])\r\n\r\nConverts each tab in the string to some number of spaces, as defined by\r\n$tabLength. By default, each tab is converted to 4 consecutive spaces.\r\n\r\n```php\r\nS::create(' String speech = \"Hi\"')->toSpaces();\r\nS::toSpaces(' String speech = \"Hi\"'); // ' String speech = \"Hi\"'\r\n```\r\n\r\n#### toTabs\r\n\r\n$stringy->toTabs([ tabLength = 4 ])\r\n\r\nS::toTabs(string $str, [, int $tabLength = 4 ])\r\n\r\nConverts each occurrence of some consecutive number of spaces, as defined\r\nby $tabLength, to a tab. By default, each 4 consecutive spaces are\r\nconverted to a tab.\r\n\r\n```php\r\nS::create(' fòô bàř')->toTabs();\r\nS::toTabs(' fòô bàř'); // ' fòô bàř'\r\n```\r\n\r\n#### toUpperCase\r\n\r\n$stringy->toUpperCase()\r\n\r\nS::toUpperCase(string $str [, string $encoding ])\r\n\r\nConverts all characters in the string to uppercase. An alias for PHP's\r\nmb_strtoupper().\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->toUpperCase();\r\nS::toUpperCase('fòô bàř', 'UTF-8'); // 'FÒÔ BÀŘ'\r\n```\r\n\r\n#### trim\r\n\r\n$stringy->trim()\r\n\r\nS::trim(string $str)\r\n\r\nReturns the trimmed string. An alias for PHP's trim() function.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->trim();\r\nS::trim(' fòô bàř '); // 'fòô bàř'\r\n```\r\n\r\n#### truncate\r\n\r\n$stringy->truncate(int $length, [, string $substring = '' ])\r\n\r\nS::truncate(string $str, int $length, [, string $substring = '' [, string $encoding ]])\r\n\r\nTruncates the string to a given length. If $substring is provided, and\r\ntruncating occurs, the string is further truncated so that the substring\r\nmay be appended without exceeding the desired length.\r\n\r\n```php\r\nS::create('What are your plans today?')->truncate(19, '...');\r\nS::truncate('What are your plans today?', 19, '...'); // 'What are your pl...'\r\n```\r\n\r\n#### underscored\r\n\r\n$stringy->underscored();\r\n\r\nS::underscored(string $str [, string $encoding ])\r\n\r\nReturns a lowercase and trimmed string separated by underscores.\r\nUnderscores are inserted before uppercase characters (with the exception\r\nof the first character of the string), and in place of spaces as well as dashes.\r\n\r\n```php\r\nS::create('TestUCase')->underscored();\r\nS::underscored('TestUCase'); // 'test_u_case'\r\n```\r\n\r\n#### upperCamelize\r\n\r\n$stringy->upperCamelize();\r\n\r\nS::upperCamelize(string $str [, string $encoding ])\r\n\r\nReturns an UpperCamelCase version of the supplied string. It trims\r\nsurrounding spaces, capitalizes letters following digits, spaces, dashes\r\nand underscores, and removes spaces, dashes, underscores.\r\n\r\n```php\r\nS::create('Upper Camel-Case')->upperCamelize();\r\nS::upperCamelize('Upper Camel-Case'); // 'UpperCamelCase'\r\n```\r\n\r\n#### upperCaseFirst\r\n\r\n$stringy->upperCaseFirst();\r\n\r\nS::upperCaseFirst(string $str [, string $encoding ])\r\n\r\nConverts the first character of the supplied string to upper case.\r\n\r\n```php\r\nS::create('σ test', 'UTF-8')->upperCaseFirst();\r\nS::upperCaseFirst('σ test', 'UTF-8'); // 'Σ test'\r\n```\r\n\r\n## Tests\r\n\r\nFrom the project directory, tests can be ran using `phpunit`\r\n\r\n## License\r\n\r\nReleased under the MIT License - see `LICENSE.txt` for details.\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file +{"name":"Stringy","tagline":"A PHP string manipulation library with multibyte support","body":"![Stringy](http://danielstjules.com/stringy/logo.png)\r\n\r\nA PHP library with a variety of string manipulation functions with multibyte\r\nsupport. Offers both OO method chaining and a procedural-style static wrapper.\r\nCompatible with PHP 5.3+. Inspired by underscore.string.js.\r\n\r\n[![Build Status](https://travis-ci.org/danielstjules/Stringy.png)](https://travis-ci.org/danielstjules/Stringy)\r\n\r\n* [Requiring/Loading](#requiringloading)\r\n* [OO and Procedural](#oo-and-procedural)\r\n* [Implemented Interfaces](#implemented-interfaces)\r\n* [Methods](#methods)\r\n * [at](#at)\r\n * [camelize](#camelize)\r\n * [chars](#chars)\r\n * [collapseWhitespace](#collapsewhitespace)\r\n * [contains](#contains)\r\n * [countSubstr](#countsubstr)\r\n * [create](#create)\r\n * [dasherize](#dasherize)\r\n * [endsWith](#endswith)\r\n * [ensureLeft](#ensureleft)\r\n * [ensureRight](#ensureright)\r\n * [first](#first)\r\n * [getEncoding](#getencoding)\r\n * [humanize](#humanize)\r\n * [insert](#insert)\r\n * [isAlpha](#isalpha)\r\n * [isAlphanumeric](#isalphanumeric)\r\n * [isBlank](#isblank)\r\n * [isHexadecimal](#ishexadecimal)\r\n * [isJson](#isjson)\r\n * [isLowerCase](#islowercase)\r\n * [isSerialized](#isserialized)\r\n * [isUpperCase](#isuppercase)\r\n * [last](#last)\r\n * [length](#length)\r\n * [longestCommonPrefix](#longestcommonprefix)\r\n * [longestCommonSuffix](#longestcommonsuffix)\r\n * [longestCommonSubstring](#longestcommonsubstring)\r\n * [lowerCaseFirst](#lowercasefirst)\r\n * [pad](#pad)\r\n * [padBoth](#padboth)\r\n * [padLeft](#padleft)\r\n * [padRight](#padright)\r\n * [regexReplace](#regexreplace)\r\n * [removeLeft](#removeleft)\r\n * [removeRight](#removeright)\r\n * [replace](#replace)\r\n * [reverse](#reverse)\r\n * [safeTruncate](#safetruncate)\r\n * [shuffle](#shuffle)\r\n * [slugify](#slugify)\r\n * [startsWith](#startswith)\r\n * [substr](#substr)\r\n * [surround](#surround)\r\n * [swapCase](#swapcase)\r\n * [tidy](#tidy)\r\n * [titleize](#titleize)\r\n * [toAscii](#toascii)\r\n * [toLowerCase](#tolowercase)\r\n * [toSpaces](#tospaces)\r\n * [toTabs](#totabs)\r\n * [toUpperCase](#touppercase)\r\n * [trim](#trim)\r\n * [truncate](#truncate)\r\n * [underscored](#underscored)\r\n * [upperCamelize](#uppercamelize)\r\n * [upperCaseFirst](#uppercasefirst)\r\n* [Links](#links)\r\n* [Tests](#tests)\r\n* [License](#license)\r\n\r\n## Requiring/Loading\r\n\r\nIf you're using Composer to manage dependencies, you can include the following\r\nin your composer.json file:\r\n\r\n \"require\": {\r\n \"danielstjules/stringy\": \"dev-master\"\r\n }\r\n\r\nThen, after running `composer update` or `php composer.phar update`, you can\r\nload the class using Composer's autoloading:\r\n\r\n```php\r\nrequire 'vendor/autoload.php';\r\n```\r\n\r\nOtherwise, you can simply require the file directly:\r\n\r\n```php\r\nrequire_once 'path/to/Stringy/src/Stringy.php';\r\n// or\r\nrequire_once 'path/to/Stringy/src/StaticStringy.php';\r\n```\r\n\r\nAnd in either case, I'd suggest using an alias.\r\n\r\n```php\r\nuse Stringy\\Stringy as S;\r\n// or\r\nuse Stringy\\StaticStringy as S;\r\n```\r\n\r\n## OO and Procedural\r\n\r\nThe library offers both OO method chaining with `Stringy\\Stringy`, as well as\r\nprocedural-style static method calls with `Stringy\\StaticStringy`. An example\r\nof the former is the following:\r\n\r\n```php\r\nuse Stringy\\Stringy as S;\r\necho S::create('Fòô Bàř', 'UTF-8')->collapseWhitespace()->swapCase(); // 'fÒÔ bÀŘ'\r\n```\r\n\r\n`Stringy\\Stringy` has a __toString() method, which returns the current string\r\nwhen the object is used in a string context, ie:\r\n`(string) S::create('foo') // 'foo'`\r\n\r\nUsing the static wrapper, an alternative is the following:\r\n\r\n```php\r\nuse Stringy\\StaticStringy as S;\r\n$string = S::collapseWhitespace('Fòô Bàř', 'UTF-8');\r\necho S::swapCase($string, 'UTF-8'); // 'fÒÔ bÀŘ'\r\n```\r\n\r\n## Implemented Interfaces\r\n\r\n`Stringy\\Stringy` implements the `IteratorAggregate` interface, meaning that\r\n`foreach` can be used with an instance of the class:\r\n\r\n``` php\r\n$stringy = S::create('Fòô Bàř', 'UTF-8');\r\nforeach ($stringy as $char) {\r\n echo $char;\r\n}\r\n// 'Fòô Bàř'\r\n```\r\n\r\nIt implements the `Countable` interface, enabling the use of `count()` to\r\nretrieve the number of characters in the string:\r\n\r\n``` php\r\n$stringy = S::create('Fòô', 'UTF-8');\r\ncount($stringy); // 3\r\n```\r\n\r\nFurthermore, the `ArrayAccess` interface has been implemented. As a result,\r\n`isset()` can be used to check if a character at a specific index exists. And\r\nsince `Stringy\\Stringy` is immutable, any call to `offsetSet` or `offsetUnset`\r\nwill throw an exception. `offsetGet` has been implemented, however, and accepts\r\nboth positive and negative indexes. Invalid indexes result in an\r\n`OutOfBoundsException`.\r\n\r\n``` php\r\n$stringy = S::create('Bàř', 'UTF-8');\r\necho $stringy[2]; // 'ř'\r\necho $stringy[-2]; // 'à'\r\nisset($stringy[-4]); // false\r\n\r\n$stringy[3]; // OutOfBoundsException\r\n$stringy[2] = 'a'; // Exception\r\n```\r\n\r\n## Methods\r\n\r\nIn the list below, any static method other than S::create refers to a method in\r\n`Stringy\\StaticStringy`. For all others, they're found in `Stringy\\Stringy`.\r\nFurthermore, all methods that return a Stringy object or string do not modify\r\nthe original. Stringy objects are immutable.\r\n\r\n*Note: If `$encoding` is not given, it defaults to `mb_internal_encoding()`.*\r\n\r\n#### at\r\n\r\n$stringy->at(int $index)\r\n\r\nS::at(int $index [, string $encoding ])\r\n\r\nReturns the character at $index, with indexes starting at 0.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->at(6);\r\nS::at('fòô bàř', 6, 'UTF-8'); // 'ř'\r\n```\r\n\r\n#### camelize\r\n\r\n$stringy->camelize();\r\n\r\nS::camelize(string $str [, string $encoding ])\r\n\r\nReturns a camelCase version of the string. Trims surrounding spaces,\r\ncapitalizes letters following digits, spaces, dashes and underscores,\r\nand removes spaces, dashes, as well as underscores.\r\n\r\n```php\r\nS::create('Camel-Case')->camelize();\r\nS::camelize('Camel-Case'); // 'camelCase'\r\n```\r\n\r\n#### chars\r\n\r\n$stringy->chars();\r\n\r\nS::chars(string $str [, string $encoding ])\r\n\r\nReturns an array consisting of the characters in the string.\r\n\r\n```php\r\nS::create('Fòô Bàř', 'UTF-8')->chars();\r\nS::chars('Fòô Bàř', 'UTF-8'); // array(F', 'ò', 'ô', ' ', 'B', 'à', 'ř')\r\n```\r\n\r\n#### collapseWhitespace\r\n\r\n$stringy->collapseWhitespace()\r\n\r\nS::collapseWhitespace(string $str [, string $encoding ])\r\n\r\nTrims the string and replaces consecutive whitespace characters with a\r\nsingle space. This includes tabs and newline characters, as well as\r\nmultibyte whitespace such as the thin space and ideographic space.\r\n\r\n```php\r\nS::create(' Ο συγγραφέας ')->collapseWhitespace();\r\nS::collapseWhitespace(' Ο συγγραφέας '); // 'Ο συγγραφέας'\r\n```\r\n\r\n#### contains\r\n\r\n$stringy->contains(string $needle [, boolean $caseSensitive = true ])\r\n\r\nS::contains(string $haystack, string $needle [, boolean $caseSensitive = true [, string $encoding ]])\r\n\r\nReturns true if the string contains $needle, false otherwise. By default,\r\nthe comparison is case-sensitive, but can be made insensitive\r\nby setting $caseSensitive to false.\r\n\r\n```php\r\nS::create('Ο συγγραφέας είπε', 'UTF-8')->contains('συγγραφέας');\r\nS::contains('Ο συγγραφέας είπε', 'συγγραφέας', 'UTF-8'); // true\r\n```\r\n\r\n#### countSubstr\r\n\r\n$stringy->countSubstr(string $substring [, boolean $caseSensitive = true ])\r\n\r\nS::countSubstr(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])\r\n\r\nReturns the number of occurrences of $substring in the given string.\r\nBy default, the comparison is case-sensitive, but can be made insensitive\r\nby setting $caseSensitive to false.\r\n\r\n```php\r\nS::create('Ο συγγραφέας είπε', 'UTF-8')->countSubstr('α');\r\nS::countSubstr('Ο συγγραφέας είπε', 'α', 'UTF-8'); // 2\r\n```\r\n\r\n#### create\r\n\r\nS::create(mixed $str, [, $encoding ])\r\n\r\nCreates a Stringy object and assigns both str and encoding properties\r\nthe supplied values. $str is cast to a string prior to assignment, and if\r\n$encoding is not specified, it defaults to mb_internal_encoding(). It\r\nthen returns the initialized object. Throws an InvalidArgumentException\r\nif the first argument is an array or object without a __toString method.\r\n\r\n```php\r\n$stringy = S::create('fòô bàř', 'UTF-8'); // 'fòô bàř'\r\n```\r\n\r\n#### dasherize\r\n\r\n$stringy->dasherize();\r\n\r\nS::dasherize(string $str [, string $encoding ])\r\n\r\nReturns a lowercase and trimmed string separated by dashes. Dashes are\r\ninserted before uppercase characters (with the exception of the first\r\ncharacter of the string), and in place of spaces as well as underscores.\r\n\r\n```php\r\nS::create('TestDCase')->dasherize();\r\nS::dasherize('TestDCase'); // 'test-d-case'\r\n```\r\n\r\n#### endsWith\r\n\r\n$stringy->endsWith(string $substring [, boolean $caseSensitive = true ])\r\n\r\nS::endsWith(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])\r\n\r\nReturns true if the string ends with $substring, false otherwise. By\r\ndefault, the comparison is case-sensitive, but can be made insensitive by\r\nsetting $caseSensitive to false.\r\n\r\n```php\r\nS::create('FÒÔ bàřs', 'UTF-8')->endsWith('àřs', true);\r\nS::endsWith('FÒÔ bàřs', 'àřs', true, 'UTF-8'); // true\r\n```\r\n\r\n#### ensureLeft\r\n\r\n$stringy->ensureLeft(string $substring)\r\n\r\nS::ensureLeft(string $substring [, string $encoding ])\r\n\r\nEnsures that the string begins with $substring. If it doesn't, it's prepended.\r\n\r\n```php\r\nS::create('foobar')->ensureLeft('http://');\r\nS::ensureLeft('foobar', 'http://'); // 'http://foobar'\r\n```\r\n\r\n#### ensureRight\r\n\r\n$stringy->ensureRight(string $substring)\r\n\r\nS::ensureRight(string $substring [, string $encoding ])\r\n\r\nEnsures that the string begins with $substring. If it doesn't, it's appended.\r\n\r\n```php\r\nS::create('foobar')->ensureRight('.com');\r\nS::ensureRight('foobar', '.com'); // 'foobar.com'\r\n```\r\n\r\n#### first\r\n\r\n$stringy->first(int $n)\r\n\r\nS::first(int $n [, string $encoding ])\r\n\r\nReturns the first $n characters of the string.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->first(3);\r\nS::first('fòô bàř', 3, 'UTF-8'); // 'fòô'\r\n```\r\n\r\n#### getEncoding\r\n\r\n$stringy->getEncoding()\r\n\r\nReturns the encoding used by the Stringy object.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->getEncoding(); // 'UTF-8'\r\n```\r\n\r\n#### humanize\r\n\r\n$stringy->humanize()\r\n\r\nS::humanize(string $str [, string $encoding ])\r\n\r\nCapitalizes the first word of the string, replaces underscores with\r\nspaces, and strips '_id'.\r\n\r\n```php\r\nS::create('author_id')->humanize();\r\nS::humanize('author_id'); // 'Author'\r\n```\r\n\r\n#### insert\r\n\r\n$stringy->insert(int $index, string $substring)\r\n\r\nS::insert(string $str, int $index, string $substring [, string $encoding ])\r\n\r\nInserts $substring into the string at the $index provided.\r\n\r\n```php\r\nS::create('fòô bà', 'UTF-8')->insert('ř', 6);\r\nS::insert('fòô bà', 'ř', 6, 'UTF-8'); // 'fòô bàř'\r\n```\r\n\r\n#### isAlpha\r\n\r\n$stringy->isAlpha()\r\n\r\nS::isAlpha(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only alphabetic chars, false otherwise.\r\n\r\n```php\r\nS::create('丹尼爾', 'UTF-8')->isAlpha();\r\nS::isAlpha('丹尼爾', 'UTF-8'); // true\r\n```\r\n\r\n#### isAlphanumeric\r\n\r\n$stringy->isAlphanumeric()\r\n\r\nS::isAlphanumeric(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only alphabetic and numeric chars, false\r\notherwise.\r\n\r\n```php\r\nS::create('دانيال1', 'UTF-8')->isAlphanumeric();\r\nS::isAlphanumeric('دانيال1', 'UTF-8'); // true\r\n```\r\n\r\n#### isBlank\r\n\r\n$stringy->isBlank()\r\n\r\nS::isBlank(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only whitespace chars, false otherwise.\r\n\r\n```php\r\nS::create(\"\\n\\t \\v\\f\")->isBlank();\r\nS::isBlank(\"\\n\\t \\v\\f\"); // true\r\n```\r\n\r\n#### isHexadecimal\r\n\r\n$stringy->isHexadecimal()\r\n\r\nS::isHexadecimal(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only hexadecimal chars, false otherwise.\r\n\r\n```php\r\nS::create('A102F')->isHexadecimal();\r\nS::isHexadecimal('A102F'); // true\r\n```\r\n\r\n#### isJson\r\n\r\n$stringy->isJson()\r\n\r\nS::isJson(string $str [, string $encoding ])\r\n\r\nReturns true if the string is JSON, false otherwise.\r\n\r\n```php\r\nS::create('{\"foo\":\"bar\"}')->isJson();\r\nS::isJson('{\"foo\":\"bar\"}'); // true\r\n```\r\n\r\n#### isLowerCase\r\n\r\n$stringy->isLowerCase()\r\n\r\nS::isLowerCase(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only lower case chars, false otherwise.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->isLowerCase();\r\nS::isLowerCase('fòô bàř', 'UTF-8'); // true\r\n```\r\n\r\n#### isSerialized\r\n\r\n$stringy->isSerialized()\r\n\r\nS::isSerialized(string $str [, string $encoding ])\r\n\r\nReturns true if the string is serialized, false otherwise.\r\n\r\n```php\r\nS::create('a:1:{s:3:\"foo\";s:3:\"bar\";}', 'UTF-8')->isSerialized();\r\nS::isSerialized('a:1:{s:3:\"foo\";s:3:\"bar\";}', 'UTF-8'); // true\r\n```\r\n\r\n#### isUpperCase\r\n\r\n$stringy->isUpperCase()\r\n\r\nS::isUpperCase(string $str [, string $encoding ])\r\n\r\nReturns true if the string contains only upper case chars, false otherwise.\r\n\r\n```php\r\nS::create('FÒÔBÀŘ', 'UTF-8')->isUpperCase();\r\nS::isUpperCase('FÒÔBÀŘ', 'UTF-8'); // true\r\n```\r\n\r\n#### last\r\n\r\n$stringy->last(int $n)\r\n\r\nS::last(int $n [, string $encoding ])\r\n\r\nReturns the last $n characters of the string.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->last(3);\r\nS::last('fòô bàř', 3, 'UTF-8'); // 'bàř'\r\n```\r\n\r\n#### length\r\n\r\n$stringy->length()\r\n\r\nS::length(string $str [, string $encoding ])\r\n\r\nReturns the length of the string. An alias for PHP's mb_strlen() function.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->length();\r\nS::length('fòô bàř', 'UTF-8'); // 7\r\n```\r\n\r\n#### longestCommonPrefix\r\n\r\n$stringy->longestCommonPrefix(string $otherStr)\r\n\r\nS::longestCommonPrefix(string $str, string $otherStr [, $encoding ])\r\n\r\nReturns the longest common prefix between the string and $otherStr.\r\n\r\n```php\r\nS::create('fòô bar', 'UTF-8')->longestCommonPrefix('fòr bar');\r\nS::longestCommonPrefix('fòô bar', 'fòr bar', 'UTF-8'); // 'fò'\r\n```\r\n\r\n#### longestCommonSuffix\r\n\r\n$stringy->longestCommonSuffix(string $otherStr)\r\n\r\nS::longestCommonSuffix(string $str, string $otherStr [, $encoding ])\r\n\r\nReturns the longest common suffix between the string and $otherStr.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->longestCommonSuffix('fòr bàř');\r\nS::longestCommonSuffix('fòô bàř', 'fòr bàř', 'UTF-8'); // ' bàř'\r\n```\r\n\r\n#### longestCommonSubstring\r\n\r\n$stringy->longestCommonSubstring(string $otherStr)\r\n\r\nS::longestCommonSubstring(string $str, string $otherStr [, $encoding ])\r\n\r\nReturns the longest common substring between the string and $otherStr. In the\r\ncase of ties, it returns that which occurs first.\r\n\r\n```php\r\nS::create('foo bar')->longestCommonSubstring('boo far');\r\nS::longestCommonSubstring('foo bar', 'boo far'); // 'oo '\r\n```\r\n\r\n#### lowerCaseFirst\r\n\r\n$stringy->lowerCaseFirst();\r\n\r\nS::lowerCaseFirst(string $str [, string $encoding ])\r\n\r\nConverts the first character of the supplied string to lower case.\r\n\r\n```php\r\nS::create('Σ test', 'UTF-8')->lowerCaseFirst();\r\nS::lowerCaseFirst('Σ test', 'UTF-8'); // 'σ test'\r\n```\r\n\r\n#### pad\r\n\r\n$stringy->pad(int $length [, string $padStr = ' ' [, string $padType = 'right' ]])\r\n\r\nS::pad(string $str , int $length [, string $padStr = ' ' [, string $padType = 'right' [, string $encoding ]]])\r\n\r\nPads the string to a given length with $padStr. If length is less than\r\nor equal to the length of the string, no padding takes places. The default\r\nstring used for padding is a space, and the default type (one of 'left',\r\n'right', 'both') is 'right'. Throws an InvalidArgumentException if\r\n$padType isn't one of those 3 values.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->pad( 10, '¬ø', 'left');\r\nS::pad('fòô bàř', 10, '¬ø', 'left', 'UTF-8'); // '¬ø¬fòô bàř'\r\n```\r\n\r\n#### padBoth\r\n\r\n$stringy->padBoth(int $length [, string $padStr = ' ' ])\r\n\r\nS::padBoth(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])\r\n\r\nReturns a new string of a given length such that both sides of the string\r\nstring are padded. Alias for pad() with a $padType of 'both'.\r\n\r\n```php\r\nS::create('foo bar')->padBoth(9, ' ');\r\nS::padBoth('foo bar', 9, ' '); // ' foo bar '\r\n```\r\n\r\n#### padLeft\r\n\r\n$stringy->padLeft(int $length [, string $padStr = ' ' ])\r\n\r\nS::padLeft(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])\r\n\r\nReturns a new string of a given length such that the beginning of the\r\nstring is padded. Alias for pad() with a $padType of 'left'.\r\n\r\n```php\r\nS::create($str, $encoding)->padLeft($length, $padStr);\r\nS::padLeft('foo bar', 9, ' '); // ' foo bar'\r\n```\r\n\r\n#### padRight\r\n\r\n$stringy->padRight(int $length [, string $padStr = ' ' ])\r\n\r\nS::padRight(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])\r\n\r\nReturns a new string of a given length such that the end of the string is\r\npadded. Alias for pad() with a $padType of 'right'.\r\n\r\n```php\r\nS::create('foo bar')->padRight(10, '_*');\r\nS::padRight('foo bar', 10, '_*'); // 'foo bar_*_'\r\n```\r\n\r\n#### regexReplace\r\n\r\n$stringy->regexReplace(string $pattern, string $replacement [, string $options = 'msr'])\r\n\r\nS::regexReplace(string $str, string $pattern, string $replacement [, string $options = 'msr' [, string $encoding ]])\r\n\r\nReplaces all occurrences of $pattern in $str by $replacement. An alias\r\nfor mb_ereg_replace(). Note that the 'i' option with multibyte patterns\r\nin mb_ereg_replace() requires PHP 5.4+. This is due to a lack of support\r\nin the bundled version of Oniguruma in PHP 5.3.\r\n\r\n```php\r\nS::create('fòô ', 'UTF-8')->regexReplace('f[òô]+\\s', 'bàř', 'msr');\r\nS::regexReplace('fòô ', 'f[òô]+\\s', 'bàř', 'msr', 'UTF-8'); // 'bàř'\r\n```\r\n\r\n#### removeLeft\r\n\r\n$stringy->removeLeft(string $substring)\r\n\r\nS::removeLeft(string $str, string $substring [, string $encoding ])\r\n\r\nReturns a new string with the prefix $substring removed, if present.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->removeLeft('fòô ');\r\nS::removeLeft('fòô bàř', 'fòô ', 'UTF-8'); // 'bàř'\r\n```\r\n\r\n#### removeRight\r\n\r\n$stringy->removeRight(string $substring)\r\n\r\nS::removeRight(string $str, string $substring [, string $encoding ])\r\n\r\nReturns a new string with the suffix $substring removed, if present.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->removeRight(' bàř');\r\nS::removeRight('fòô bàř', ' bàř', 'UTF-8'); // 'fòô'\r\n```\r\n\r\n#### replace\r\n\r\n$stringy->replace(string $search, string $replacement)\r\n\r\nS::replace(string $str, string $search, string $replacement [, string $encoding ])\r\n\r\nReplaces all occurrences of $search in $str by $replacement.\r\n\r\n```php\r\nS::create('fòô bàř fòô bàř', 'UTF-8')->replace('fòô ', '');\r\nS::replace('fòô bàř fòô bàř', 'fòô ', '', 'UTF-8'); // 'bàř bàř'\r\n```\r\n\r\n#### reverse\r\n\r\n$stringy->reverse()\r\n\r\nS::reverse(string $str, [, string $encoding ])\r\n\r\nReturns a reversed string. A multibyte version of strrev().\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->reverse();\r\nS::reverse('fòô bàř', 'UTF-8'); // 'řàb ôòf'\r\n```\r\n\r\n#### safeTruncate\r\n\r\n$stringy->safeTruncate(int $length, [, string $substring = '' ])\r\n\r\nS::safeTruncate(string $str, int $length, [, string $substring = '' [, string $encoding ]])\r\n\r\nTruncates the string to a given length, while ensuring that it does not\r\nsplit words. If $substring is provided, and truncating occurs, the\r\nstring is further truncated so that the substring may be appended without\r\nexceeding the desired length.\r\n\r\n```php\r\nS::create('What are your plans today?')->safeTruncate(22, '...');\r\nS::safeTruncate('What are your plans today?', 22, '...'); // 'What are your plans...'\r\n```\r\n\r\n#### shuffle\r\n\r\n$stringy->shuffle()\r\n\r\nS::shuffle(string $str [, string $encoding ])\r\n\r\nA multibyte str_shuffle() function. It returns a string with its characters in\r\nrandom order.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->shuffle();\r\nS::shuffle('fòô bàř', 'UTF-8'); // 'àôřb òf'\r\n```\r\n\r\n#### slugify\r\n\r\n$stringy->slugify([ string $replacement = '-' ])\r\n\r\nS::slugify(string $str [, string $replacement = '-' ])\r\n\r\nConverts the string into an URL slug. This includes replacing non-ASCII\r\ncharacters with their closest ASCII equivalents, removing remaining\r\nnon-ASCII and non-alphanumeric characters, and replacing whitespace with\r\n$replacement. The replacement defaults to a single dash, and the string\r\nis also converted to lowercase.\r\n\r\n```php\r\nS::create('Using strings like fòô bàř')->slugify();\r\nS::slugify('Using strings like fòô bàř'); // 'using-strings-like-foo-bar'\r\n```\r\n\r\n#### startsWith\r\n\r\n$stringy->startsWith(string $substring [, boolean $caseSensitive = true ])\r\n\r\nS::startsWith(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])\r\n\r\nReturns true if the string begins with $substring, false otherwise.\r\nBy default, the comparison is case-sensitive, but can be made insensitive\r\nby setting $caseSensitive to false.\r\n\r\n```php\r\nS::create('FÒÔ bàřs', 'UTF-8')->startsWith('fòô bàř', false);\r\nS::startsWith('FÒÔ bàřs', 'fòô bàř', false, 'UTF-8'); // true\r\n```\r\n\r\n#### substr\r\n\r\n$stringy->substr(int $start [, int $length ])\r\n\r\nS::substr(string $str, int $start [, int $length [, string $encoding ]])\r\n\r\nReturns the substring beginning at $start with the specified $length.\r\nIt differs from the mb_substr() function in that providing a $length of\r\nnull will return the rest of the string, rather than an empty string.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->substr(2, 3);\r\nS::substr('fòô bàř', 2, 3, 'UTF-8'); // 'ô b'\r\n```\r\n\r\n#### surround\r\n\r\n$stringy->surround(string $substring)\r\n\r\nS::surround(string $str, string $substring)\r\n\r\nSurrounds a string with the given substring.\r\n\r\n```php\r\nS::create(' ͜ ')->surround('ʘ');\r\nS::surround(' ͜ ', 'ʘ'); // 'ʘ ͜ ʘ'\r\n```\r\n\r\n#### swapCase\r\n\r\n$stringy->swapCase();\r\n\r\nS::swapCase(string $str [, string $encoding ])\r\n\r\nReturns a case swapped version of the string.\r\n\r\n```php\r\nS::create('Ντανιλ', 'UTF-8')->swapCase();\r\nS::swapCase('Ντανιλ', 'UTF-8'); // 'νΤΑΝΙΛ'\r\n```\r\n\r\n#### tidy\r\n\r\n$stringy->tidy()\r\n\r\nS::tidy(string $str)\r\n\r\nReturns a string with smart quotes, ellipsis characters, and dashes from\r\nWindows-1252 (commonly used in Word documents) replaced by their ASCII equivalents.\r\n\r\n```php\r\nS::create('“I see…”')->tidy();\r\nS::tidy('“I see…”'); // '\"I see...\"'\r\n```\r\n\r\n#### titleize\r\n\r\n$stringy->titleize([ string $encoding ])\r\n\r\nS::titleize(string $str [, array $ignore [, string $encoding ]])\r\n\r\nReturns a trimmed string with the first letter of each word capitalized.\r\nIgnores the case of other letters, preserving any acronyms. Also accepts\r\nan array, $ignore, allowing you to list words not to be capitalized.\r\n\r\n```php\r\n$ignore = array('at', 'by', 'for', 'in', 'of', 'on', 'out', 'to', 'the');\r\nS::create('i like to watch DVDs at home', 'UTF-8')->titleize($ignore);\r\nS::titleize('i like to watch DVDs at home', $ignore, 'UTF-8');\r\n// 'I Like to Watch DVDs at Home'\r\n```\r\n\r\n#### toAscii\r\n\r\n$stringy->toAscii()\r\n\r\nS::toAscii(string $str)\r\n\r\nReturns an ASCII version of the string. A set of non-ASCII characters are\r\nreplaced with their closest ASCII counterparts, and the rest are removed.\r\n\r\n```php\r\nS::create('fòô bàř')->toAscii();\r\nS::toAscii('fòô bàř'); // 'foo bar'\r\n```\r\n\r\n#### toLowerCase\r\n\r\n$stringy->toLowerCase()\r\n\r\nS::toLowerCase(string $str [, string $encoding ])\r\n\r\nConverts all characters in the string to lowercase. An alias for PHP's\r\nmb_strtolower().\r\n\r\n```php\r\nS::create('FÒÔ BÀŘ', 'UTF-8')->toLowerCase();\r\nS::toLowerCase('FÒÔ BÀŘ', 'UTF-8'); // 'fòô bàř'\r\n```\r\n\r\n#### toSpaces\r\n\r\n$stringy->toSpaces([ tabLength = 4 ])\r\n\r\nS::toSpaces(string $str, [, int $tabLength = 4 ])\r\n\r\nConverts each tab in the string to some number of spaces, as defined by\r\n$tabLength. By default, each tab is converted to 4 consecutive spaces.\r\n\r\n```php\r\nS::create(' String speech = \"Hi\"')->toSpaces();\r\nS::toSpaces(' String speech = \"Hi\"'); // ' String speech = \"Hi\"'\r\n```\r\n\r\n#### toTabs\r\n\r\n$stringy->toTabs([ tabLength = 4 ])\r\n\r\nS::toTabs(string $str, [, int $tabLength = 4 ])\r\n\r\nConverts each occurrence of some consecutive number of spaces, as defined\r\nby $tabLength, to a tab. By default, each 4 consecutive spaces are\r\nconverted to a tab.\r\n\r\n```php\r\nS::create(' fòô bàř')->toTabs();\r\nS::toTabs(' fòô bàř'); // ' fòô bàř'\r\n```\r\n\r\n#### toUpperCase\r\n\r\n$stringy->toUpperCase()\r\n\r\nS::toUpperCase(string $str [, string $encoding ])\r\n\r\nConverts all characters in the string to uppercase. An alias for PHP's\r\nmb_strtoupper().\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->toUpperCase();\r\nS::toUpperCase('fòô bàř', 'UTF-8'); // 'FÒÔ BÀŘ'\r\n```\r\n\r\n#### trim\r\n\r\n$stringy->trim()\r\n\r\nS::trim(string $str)\r\n\r\nReturns the trimmed string. An alias for PHP's trim() function.\r\n\r\n```php\r\nS::create('fòô bàř', 'UTF-8')->trim();\r\nS::trim(' fòô bàř '); // 'fòô bàř'\r\n```\r\n\r\n#### truncate\r\n\r\n$stringy->truncate(int $length, [, string $substring = '' ])\r\n\r\nS::truncate(string $str, int $length, [, string $substring = '' [, string $encoding ]])\r\n\r\nTruncates the string to a given length. If $substring is provided, and\r\ntruncating occurs, the string is further truncated so that the substring\r\nmay be appended without exceeding the desired length.\r\n\r\n```php\r\nS::create('What are your plans today?')->truncate(19, '...');\r\nS::truncate('What are your plans today?', 19, '...'); // 'What are your pl...'\r\n```\r\n\r\n#### underscored\r\n\r\n$stringy->underscored();\r\n\r\nS::underscored(string $str [, string $encoding ])\r\n\r\nReturns a lowercase and trimmed string separated by underscores.\r\nUnderscores are inserted before uppercase characters (with the exception\r\nof the first character of the string), and in place of spaces as well as dashes.\r\n\r\n```php\r\nS::create('TestUCase')->underscored();\r\nS::underscored('TestUCase'); // 'test_u_case'\r\n```\r\n\r\n#### upperCamelize\r\n\r\n$stringy->upperCamelize();\r\n\r\nS::upperCamelize(string $str [, string $encoding ])\r\n\r\nReturns an UpperCamelCase version of the supplied string. It trims\r\nsurrounding spaces, capitalizes letters following digits, spaces, dashes\r\nand underscores, and removes spaces, dashes, underscores.\r\n\r\n```php\r\nS::create('Upper Camel-Case')->upperCamelize();\r\nS::upperCamelize('Upper Camel-Case'); // 'UpperCamelCase'\r\n```\r\n\r\n#### upperCaseFirst\r\n\r\n$stringy->upperCaseFirst();\r\n\r\nS::upperCaseFirst(string $str [, string $encoding ])\r\n\r\nConverts the first character of the supplied string to upper case.\r\n\r\n```php\r\nS::create('σ test', 'UTF-8')->upperCaseFirst();\r\nS::upperCaseFirst('σ test', 'UTF-8'); // 'Σ test'\r\n```\r\n\r\n## Links\r\n\r\nThe following is a list of libraries that extend Stringy:\r\n\r\n * [SliceableStringy](https://github.com/danielstjules/SliceableStringy):\r\nPython-like string slices in PHP\r\n\r\n## Tests\r\n\r\nFrom the project directory, tests can be ran using `phpunit`\r\n\r\n## License\r\n\r\nReleased under the MIT License - see `LICENSE.txt` for details.\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file