1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-07 22:06:36 +02:00

Merge pull request #160 from danielstjules/3.x-dev

3.x
This commit is contained in:
Daniel St. Jules
2017-03-08 19:44:04 -05:00
committed by GitHub
7 changed files with 1342 additions and 1265 deletions

View File

@@ -10,10 +10,6 @@ sudo: false
matrix: matrix:
fast_finish: true fast_finish: true
include: include:
- php: 5.3
env: polyfill='true'
- php: 5.3
env: polyfill='false'
- php: 5.4 - php: 5.4
env: polyfill='true' env: polyfill='true'
- php: 5.4 - php: 5.4

View File

@@ -1,13 +1,16 @@
![Stringy](http://danielstjules.com/github/stringy-logo.png) ![Stringy](http://danielstjules.com/github/stringy-logo.png)
A PHP string manipulation library with multibyte support. Compatible with PHP A PHP string manipulation library with multibyte support. Compatible with PHP
5.3+, PHP 7, and HHVM. Refer to the [1.x branch](https://github.com/danielstjules/Stringy/tree/1.x) 5.4+, PHP 7, and HHVM.
for older documentation.
``` php ``` php
s('string')->toTitleCase()->ensureRight('y') == 'Stringy' s('string')->toTitleCase()->ensureRight('y') == 'Stringy'
``` ```
Refer to the [1.x branch](https://github.com/danielstjules/Stringy/tree/1.x) or
[2.x branch](https://github.com/danielstjules/Stringy/tree/2.x) for older
documentation.
[![Build Status](https://api.travis-ci.org/danielstjules/Stringy.svg?branch=master)](https://travis-ci.org/danielstjules/Stringy) [![Build Status](https://api.travis-ci.org/danielstjules/Stringy.svg?branch=master)](https://travis-ci.org/danielstjules/Stringy)
[![Total Downloads](https://poser.pugx.org/danielstjules/stringy/downloads)](https://packagist.org/packages/danielstjules/stringy) [![Total Downloads](https://poser.pugx.org/danielstjules/stringy/downloads)](https://packagist.org/packages/danielstjules/stringy)
[![License](https://poser.pugx.org/danielstjules/stringy/license)](https://packagist.org/packages/danielstjules/stringy) [![License](https://poser.pugx.org/danielstjules/stringy/license)](https://packagist.org/packages/danielstjules/stringy)
@@ -42,7 +45,7 @@ s('string')->toTitleCase()->ensureRight('y') == 'Stringy'
</tr> </tr>
<tr> <tr>
<td>[endsWith](#endswithstring-substring--boolean-casesensitive--true-)</td> <td>[endsWith](#endswithstring-substring--boolean-casesensitive--true-)</td>
<td>[endsWithAny](#endsWithAnystring-substrings--boolean-casesensitive--true-)</td> <td>[endsWithAny](#endswithanystring-substrings--boolean-casesensitive--true-)</td>
<td>[ensureLeft](#ensureleftstring-substring)</td> <td>[ensureLeft](#ensureleftstring-substring)</td>
<td>[ensureRight](#ensurerightstring-substring)</td> <td>[ensureRight](#ensurerightstring-substring)</td>
</tr> </tr>
@@ -74,7 +77,7 @@ s('string')->toTitleCase()->ensureRight('y') == 'Stringy'
<td>[isLowerCase](#islowercase)</td> <td>[isLowerCase](#islowercase)</td>
<td>[isSerialized](#isserialized)</td> <td>[isSerialized](#isserialized)</td>
<td>[isUpperCase](#isuppercase)</td> <td>[isUpperCase](#isuppercase)</td>
<td>[last](#last)</td> <td>[last](#lastint-n)</td>
</tr> </tr>
<tr> <tr>
<td>[length](#length)</td> <td>[length](#length)</td>
@@ -97,7 +100,7 @@ s('string')->toTitleCase()->ensureRight('y') == 'Stringy'
<tr> <tr>
<td>[removeLeft](#removeleftstring-substring)</td> <td>[removeLeft](#removeleftstring-substring)</td>
<td>[removeRight](#removerightstring-substring)</td> <td>[removeRight](#removerightstring-substring)</td>
<td>[repeat](#repeatmultiplier)</td> <td>[repeat](#repeatint-multiplier)</td>
<td>[replace](#replacestring-search-string-replacement)</td> <td>[replace](#replacestring-search-string-replacement)</td>
</tr> </tr>
<tr> <tr>
@@ -107,10 +110,10 @@ s('string')->toTitleCase()->ensureRight('y') == 'Stringy'
<td>[slugify](#slugify-string-replacement----)</td> <td>[slugify](#slugify-string-replacement----)</td>
</tr> </tr>
<tr> <tr>
<td>[startsWith](#startswithstring-substring--boolean-casesensitive--true-)</td>
<td>[startsWithAny](#startswithanystring-substrings--boolean-casesensitive--true-)</td>
<td>[slice](#sliceint-start--int-end-)</td> <td>[slice](#sliceint-start--int-end-)</td>
<td>[split](#splitstring-pattern--int-limit-)</td> <td>[split](#splitstring-pattern--int-limit-)</td>
<td>[startsWith](#startswithstring-substring--boolean-casesensitive--true-)</td>
<td>[startsWithAny](#startswithanystring-substrings--boolean-casesensitive--true-)</td>
</tr> </tr>
<tr> <tr>
<td>[stripWhitespace](#stripwhitespace)</td> <td>[stripWhitespace](#stripwhitespace)</td>
@@ -121,7 +124,7 @@ s('string')->toTitleCase()->ensureRight('y') == 'Stringy'
<tr> <tr>
<td>[tidy](#tidy)</td> <td>[tidy](#tidy)</td>
<td>[titleize](#titleize-array-ignore)</td> <td>[titleize](#titleize-array-ignore)</td>
<td>[toAscii](#toascii)</td> <td>[toAscii](#toascii-string-locale--en--bool-removeunsupported--true-)</td>
<td>[toBoolean](#toboolean)</td> <td>[toBoolean](#toboolean)</td>
</tr> </tr>
<tr> <tr>
@@ -433,7 +436,7 @@ default, the comparison is case-sensitive, but can be made insensitive by
setting $caseSensitive to false. setting $caseSensitive to false.
```php ```php
s('fòôbàř')->endsWith('bàř', true); // true s('fòôbàř')->endsWith('bàř'); // true
``` ```
##### endsWithAny(string[] $substrings [, boolean $caseSensitive = true ]) ##### endsWithAny(string[] $substrings [, boolean $caseSensitive = true ])
@@ -443,7 +446,7 @@ By default, the comparison is case-sensitive, but can be made insensitive
by setting $caseSensitive to false. by setting $caseSensitive to false.
```php ```php
s('fòôbàř')->endsWith(['bàř', 'baz'], true); // true s('fòôbàř')->endsWithAny(['bàř', 'baz']); // true
``` ```
##### ensureLeft(string $substring) ##### ensureLeft(string $substring)
@@ -818,26 +821,6 @@ is also converted to lowercase.
s('Using strings like fòô bàř')->slugify(); // 'using-strings-like-foo-bar' s('Using strings like fòô bàř')->slugify(); // 'using-strings-like-foo-bar'
``` ```
##### startsWith(string $substring [, boolean $caseSensitive = true ])
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.
```php
s('FÒÔbàřbaz')->startsWith('fòôbàř', false); // true
```
##### startsWithAny(string[] $substrings [, boolean $caseSensitive = true ])
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.
```php
s('FÒÔbàřbaz')->startsWith(['fòô', 'bàř'], false); // true
```
##### slice(int $start [, int $end ]) ##### slice(int $start [, int $end ])
Returns the substring beginning at $start, and up to, but not including Returns the substring beginning at $start, and up to, but not including
@@ -859,6 +842,26 @@ results.
s('foo,bar,baz')->split(',', 2); // ['foo', 'bar'] s('foo,bar,baz')->split(',', 2); // ['foo', 'bar']
``` ```
##### startsWith(string $substring [, boolean $caseSensitive = true ])
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.
```php
s('FÒÔbàřbaz')->startsWith('fòôbàř', false); // true
```
##### startsWithAny(string[] $substrings [, boolean $caseSensitive = true ])
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.
```php
s('FÒÔbàřbaz')->startsWithAny(['fòô', 'bàř'], false); // true
```
##### stripWhitespace() ##### stripWhitespace()
Strip all whitespace characters. This includes tabs and newline Strip all whitespace characters. This includes tabs and newline
@@ -916,14 +919,19 @@ s('i like to watch television')->titleize($ignore);
// 'I Like to Watch Television' // 'I Like to Watch Television'
``` ```
##### toAscii() ##### toAscii([, string $locale = 'en' [, bool $removeUnsupported = true ]])
Returns an ASCII version of the string. A set of non-ASCII characters are 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 replaced with their closest ASCII counterparts, and the rest are removed
unless instructed otherwise. 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.
```php ```php
s('fòôbàř')->toAscii(); // 'foobar' s('fòôbàř')->toAscii(); // 'foobar'
s('äöü')->toAscii(); // 'aou'
s('äöü')->toAscii('de'); // 'aeoeue'
``` ```
##### toBoolean() ##### toBoolean()

View File

@@ -15,7 +15,7 @@
} }
], ],
"require": { "require": {
"php": ">=5.3.0", "php": ">=5.4.0",
"symfony/polyfill-mbstring": "~1.1" "symfony/polyfill-mbstring": "~1.1"
}, },
"require-dev": { "require-dev": {

View File

@@ -16,13 +16,14 @@ use ReflectionMethod;
* @method static string chars(string $str, string $encoding = null) * @method static string chars(string $str, string $encoding = null)
* @method static string collapseWhitespace(string $str, string $encoding = null) * @method static string collapseWhitespace(string $str, string $encoding = null)
* @method static bool contains(string $str, string $needle, bool $caseSensitive = true, string $encoding = null) * @method static bool contains(string $str, string $needle, bool $caseSensitive = true, string $encoding = null)
* @method static bool containsAll(string $str, string $needle, bool $caseSensitive = true, string $encoding = null) * @method static bool containsAll(string $str, string[] $needle, bool $caseSensitive = true, string $encoding = null)
* @method static bool containsAny(string $str, string $needle, bool $caseSensitive = true, string $encoding = null) * @method static bool containsAny(string $str, string[] $needle, bool $caseSensitive = true, string $encoding = null)
* @method static int count(string $str, string $encoding = null) * @method static int count(string $str, string $encoding = null)
* @method static int countSubstr(string $str, string $substring, bool $caseSensitive = true, string $encoding = null) * @method static int countSubstr(string $str, string $substring, bool $caseSensitive = true, string $encoding = null)
* @method static string dasherize(string $str, string $encoding = null) * @method static string dasherize(string $str, string $encoding = null)
* @method static string delimit(string $str, string $delimiter, string $encoding = null) * @method static string delimit(string $str, string $delimiter, string $encoding = null)
* @method static bool endsWith(string $str, string $substring, bool $caseSensitive = true, string $encoding = null) * @method static bool endsWith(string $str, string $substring, bool $caseSensitive = true, string $encoding = null)
* @method static bool endsWithAny(string $str, string[] $substrings, bool $caseSensitive = true, string $encoding = null)
* @method static string ensureLeft(string $str, string $substring, string $encoding = null) * @method static string ensureLeft(string $str, string $substring, string $encoding = null)
* @method static string ensureRight(string $str, string $substring, string $encoding = null) * @method static string ensureRight(string $str, string $substring, string $encoding = null)
* @method static string first(string $str, int $n, string $encoding = null) * @method static string first(string $str, int $n, string $encoding = null)
@@ -45,7 +46,7 @@ use ReflectionMethod;
* @method static bool isUpperCase(string $str, string $encoding = null) * @method static bool isUpperCase(string $str, string $encoding = null)
* @method static string last(string $str, string $encoding = null) * @method static string last(string $str, string $encoding = null)
* @method static int length(string $str, string $encoding = null) * @method static int length(string $str, string $encoding = null)
* @method static Stringy[] lines(string $str, string $encoding = null) * @method static string[] lines(string $str, string $encoding = null)
* @method static string longestCommonPrefix(string $str, string $otherStr, string $encoding = null) * @method static string longestCommonPrefix(string $str, string $otherStr, string $encoding = null)
* @method static string longestCommonSuffix(string $str, string $otherStr, string $encoding = null) * @method static string longestCommonSuffix(string $str, string $otherStr, string $encoding = null)
* @method static string longestCommonSubstring(string $str, string $otherStr, string $encoding = null) * @method static string longestCommonSubstring(string $str, string $otherStr, string $encoding = null)
@@ -64,15 +65,17 @@ use ReflectionMethod;
* @method static string safeTruncate(string $str, int $length, string $substring = '', string $encoding = null) * @method static string safeTruncate(string $str, int $length, string $substring = '', string $encoding = null)
* @method static string shuffle(string $str, string $encoding = null) * @method static string shuffle(string $str, string $encoding = null)
* @method static string slugify(string $str, string $replacement = '-', string $encoding = null) * @method static string slugify(string $str, string $replacement = '-', string $encoding = null)
* @method static bool startsWith(string $str, string $substring, bool $caseSensitive = true, string $encoding = null)
* @method static string slice(string $str, int $start, int $end = null, string $encoding = null) * @method static string slice(string $str, int $start, int $end = null, string $encoding = null)
* @method static string split(string $str, string $pattern, int $limit = null, string $encoding = null) * @method static string split(string $str, string $pattern, int $limit = null, string $encoding = null)
* @method static bool startsWith(string $str, string $substring, bool $caseSensitive = true, string $encoding = null)
* @method static bool startsWithAny(string $str, string[] $substrings, bool $caseSensitive = true, string $encoding = null)
* @method static string stripWhitespace(string $str, string $encoding = null)
* @method static string substr(string $str, int $start, int $length = null, string $encoding = null) * @method static string substr(string $str, int $start, int $length = null, string $encoding = null)
* @method static string surround(string $str, string $substring, string $encoding = null) * @method static string surround(string $str, string $substring, string $encoding = null)
* @method static string swapCase(string $str, string $encoding = null) * @method static string swapCase(string $str, string $encoding = null)
* @method static string tidy(string $str, string $encoding = null) * @method static string tidy(string $str, string $encoding = null)
* @method static string titleize(string $str, string $encoding = null) * @method static string titleize(string $str, string $encoding = null)
* @method static string toAscii(string $str, bool $removeUnsupported = true, string $encoding = null) * @method static string toAscii(string $str, string $language = 'en', bool $removeUnsupported = true, string $encoding = null)
* @method static bool toBoolean(string $str, string $encoding = null) * @method static bool toBoolean(string $str, string $encoding = null)
* @method static string toLowerCase(string $str, string $encoding = null) * @method static string toLowerCase(string $str, string $encoding = null)
* @method static string toSpaces(string $str, int $tabLength = 4, string $encoding = null) * @method static string toSpaces(string $str, int $tabLength = 4, string $encoding = null)
@@ -143,6 +146,16 @@ class StaticStringy
$stringy = Stringy::create($str, $encoding); $stringy = Stringy::create($str, $encoding);
return call_user_func_array(array($stringy, $name), $args); $result = call_user_func_array([$stringy, $name], $args);
$cast = function($val) {
if (is_object($val) && $val instanceof Stringy) {
return (string) $val;
} else {
return $val;
}
};
return is_array($result) ? array_map($cast, $result) : $cast($result);
} }
} }

View File

@@ -174,7 +174,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
*/ */
public function chars() public function chars()
{ {
$chars = array(); $chars = [];
for ($i = 0, $l = $this->length(); $i < $l; $i++) { for ($i = 0, $l = $this->length(); $i < $l; $i++) {
$chars[] = $this->at($i)->str; $chars[] = $this->at($i)->str;
} }
@@ -219,9 +219,9 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
* default the comparison is case-sensitive, but can be made insensitive by * default the comparison is case-sensitive, but can be made insensitive by
* setting $caseSensitive to false. * setting $caseSensitive to false.
* *
* @param array $needles Substrings to look for * @param string[] $needles Substrings to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @return bool Whether or not $str contains $needle * @return bool Whether or not $str contains $needle
*/ */
public function containsAll($needles, $caseSensitive = true) public function containsAll($needles, $caseSensitive = true)
{ {
@@ -243,9 +243,9 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
* default the comparison is case-sensitive, but can be made insensitive by * default the comparison is case-sensitive, but can be made insensitive by
* setting $caseSensitive to false. * setting $caseSensitive to false.
* *
* @param array $needles Substrings to look for * @param string[] $needles Substrings to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @return bool Whether or not $str contains $needle * @return bool Whether or not $str contains $needle
*/ */
public function containsAny($needles, $caseSensitive = true) public function containsAny($needles, $caseSensitive = true)
{ {
@@ -516,7 +516,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
*/ */
public function humanize() public function humanize()
{ {
$str = str_replace(array('_id', '_'), array('', ' '), $this->str); $str = str_replace(['_id', '_'], ['', ' '], $this->str);
return static::create($str, $this->encoding)->trim()->upperCaseFirst(); return static::create($str, $this->encoding)->trim()->upperCaseFirst();
} }
@@ -925,7 +925,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
*/ */
public function pad($length, $padStr = ' ', $padType = 'right') public function pad($length, $padStr = ' ', $padType = 'right')
{ {
if (!in_array($padType, array('left', 'right', 'both'))) { if (!in_array($padType, ['left', 'right', 'both'])) {
throw new InvalidArgumentException('Pad expects $padType ' . throw new InvalidArgumentException('Pad expects $padType ' .
"to be one of 'left', 'right' or 'both'"); "to be one of 'left', 'right' or 'both'");
} }
@@ -1180,7 +1180,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
* by setting $caseSensitive to false. * by setting $caseSensitive to false.
* *
* @param string $substring The substring to look for * @param string $substring The substring to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce
* case-sensitivity
* @return bool Whether or not $str starts with $substring * @return bool Whether or not $str starts with $substring
*/ */
public function startsWith($substring, $caseSensitive = true) public function startsWith($substring, $caseSensitive = true)
@@ -1259,13 +1260,13 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
public function split($pattern, $limit = null) public function split($pattern, $limit = null)
{ {
if ($limit === 0) { if ($limit === 0) {
return array(); return [];
} }
// mb_split errors when supplied an empty pattern in < PHP 5.4.13 // mb_split errors when supplied an empty pattern in < PHP 5.4.13
// and HHVM < 3.8 // and HHVM < 3.8
if ($pattern === '') { if ($pattern === '') {
return array(static::create($this->str, $this->encoding)); return [static::create($this->str, $this->encoding)];
} }
$regexEncoding = $this->regexEncoding(); $regexEncoding = $this->regexEncoding();
@@ -1337,7 +1338,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
*/ */
public function surround($substring) public function surround($substring)
{ {
$str = implode('', array($substring, $this->str, $substring)); $str = implode('', [$substring, $this->str, $substring]);
return static::create($str, $this->encoding); return static::create($str, $this->encoding);
} }
@@ -1376,17 +1377,17 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
*/ */
public function tidy() public function tidy()
{ {
$str = preg_replace(array( $str = preg_replace([
'/\x{2026}/u', '/\x{2026}/u',
'/[\x{201C}\x{201D}]/u', '/[\x{201C}\x{201D}]/u',
'/[\x{2018}\x{2019}]/u', '/[\x{2018}\x{2019}]/u',
'/[\x{2013}\x{2014}]/u', '/[\x{2013}\x{2014}]/u',
), array( ], [
'...', '...',
'"', '"',
"'", "'",
'-', '-',
), $this->str); ], $this->str);
return static::create($str, $this->encoding); return static::create($str, $this->encoding);
} }
@@ -1424,16 +1425,25 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
/** /**
* Returns an ASCII version of the string. A set of non-ASCII characters are * 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 * replaced with their closest ASCII counterparts, and the rest are removed
* unless instructed otherwise. * 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.
* *
* @param string $language Language of the source string
* @param bool $removeUnsupported Whether or not to remove the * @param bool $removeUnsupported Whether or not to remove the
* unsupported characters * unsupported characters
* @return static Object whose $str contains only ASCII characters * @return static Object whose $str contains only ASCII characters
*/ */
public function toAscii($removeUnsupported = true) public function toAscii($language = 'en', $removeUnsupported = true)
{ {
$str = $this->str; $str = $this->str;
$langSpecific = $this->langSpecificCharsArray($language);
if (!empty($langSpecific)) {
$str = str_replace($langSpecific[0], $langSpecific[1], $str);
}
foreach ($this->charsArray() as $key => $value) { foreach ($this->charsArray() as $key => $value) {
$str = str_replace($value, $key, $str); $str = str_replace($value, $key, $str);
} }
@@ -1459,7 +1469,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
public function toBoolean() public function toBoolean()
{ {
$key = $this->toLowerCase()->str; $key = $this->toLowerCase()->str;
$map = array( $map = [
'true' => true, 'true' => true,
'1' => true, '1' => true,
'on' => true, 'on' => true,
@@ -1468,7 +1478,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
'0' => false, '0' => false,
'off' => false, 'off' => false,
'no' => false 'no' => false
); ];
if (array_key_exists($key, $map)) { if (array_key_exists($key, $map)) {
return $map[$key]; return $map[$key];
@@ -1670,171 +1680,204 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
static $charsArray; static $charsArray;
if (isset($charsArray)) return $charsArray; if (isset($charsArray)) return $charsArray;
return $charsArray = array( return $charsArray = [
'0' => array('°', '₀', '۰', ''), '0' => ['°', '₀', '۰', ''],
'1' => array('¹', '₁', '۱', ''), '1' => ['¹', '₁', '۱', ''],
'2' => array('²', '₂', '۲', ''), '2' => ['²', '₂', '۲', ''],
'3' => array('³', '₃', '۳', ''), '3' => ['³', '₃', '۳', ''],
'4' => array('⁴', '₄', '۴', '٤', ''), '4' => ['⁴', '₄', '۴', '٤', ''],
'5' => array('⁵', '₅', '۵', '٥', ''), '5' => ['⁵', '₅', '۵', '٥', ''],
'6' => array('⁶', '₆', '۶', '٦', ''), '6' => ['⁶', '₆', '۶', '٦', ''],
'7' => array('⁷', '₇', '۷', ''), '7' => ['⁷', '₇', '۷', ''],
'8' => array('⁸', '₈', '۸', ''), '8' => ['⁸', '₈', '۸', ''],
'9' => array('⁹', '₉', '۹', ''), '9' => ['⁹', '₉', '۹', ''],
'a' => array('à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', 'a' => ['à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ',
'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ā', 'ą', 'å', 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ā', 'ą', 'å',
'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ',
'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά',
'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', 'အ', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', 'အ',
'ာ', 'ါ', 'ǻ', 'ǎ', 'ª', 'ა', 'अ', 'ا', ''), 'ာ', 'ါ', 'ǻ', 'ǎ', 'ª', 'ა', 'अ', 'ا', '', 'ä'],
'b' => array('б', 'β', 'Ъ', 'Ь', 'ب', 'ဗ', 'ბ', ''), 'b' => ['б', 'β', 'Ъ', 'Ь', 'ب', 'ဗ', 'ბ', ''],
'c' => array('ç', 'ć', 'č', 'ĉ', 'ċ', ''), 'c' => ['ç', 'ć', 'č', 'ĉ', 'ċ', ''],
'd' => array('ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', 'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ',
'д', 'δ', 'د', 'ض', 'ဍ', 'ဒ', 'დ', ''), 'д', 'δ', 'د', 'ض', 'ဍ', 'ဒ', 'დ', ''],
'e' => array('é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ', 'e' => ['é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ',
'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ', 'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ',
'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э',
'є', 'ə', 'ဧ', 'ေ', 'ဲ', 'ე', 'ए', 'إ', 'ئ', ''), 'є', 'ə', 'ဧ', 'ေ', 'ဲ', 'ე', 'ए', 'إ', 'ئ', ''],
'f' => array('ф', 'φ', 'ف', 'ƒ', 'ფ', ''), 'f' => ['ф', 'φ', 'ف', 'ƒ', 'ფ', ''],
'g' => array('ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ဂ', 'გ', 'گ', 'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ဂ', 'გ', 'گ',
''), ''],
'h' => array('ĥ', 'ħ', 'η', 'ή', 'ح', 'ه', 'ဟ', 'ှ', 'ჰ', ''), 'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه', 'ဟ', 'ှ', 'ჰ', ''],
'i' => array('í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', 'i' => ['í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į',
'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ',
'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ',
'ῗ', 'і', 'ї', 'и', 'ဣ', 'ိ', 'ီ', 'ည်', 'ǐ', 'ი', 'ῗ', 'і', 'ї', 'и', 'ဣ', 'ိ', 'ီ', 'ည်', 'ǐ', 'ი',
'इ', 'ی', ''), 'इ', 'ی', ''],
'j' => array('ĵ', 'ј', 'Ј', 'ჯ', 'ج', ''), 'j' => ['ĵ', 'ј', 'Ј', 'ჯ', 'ج', ''],
'k' => array('ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك', 'က', 'კ', 'ქ', 'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك', 'က', 'კ', 'ქ',
'ک', ''), 'ک', ''],
'l' => array('ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل', 'လ', 'ლ', 'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل', 'လ', 'ლ',
''), ''],
'm' => array('м', 'μ', 'م', 'မ', 'მ', ''), 'm' => ['м', 'μ', 'م', 'မ', 'მ', ''],
'n' => array('ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن', 'န', 'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن', 'န',
'ნ', ''), 'ნ', ''],
'o' => array('ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', 'o' => ['ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ',
'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő',
'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό',
'о', 'و', 'θ', 'ို', 'ǒ', 'ǿ', 'º', 'ო', 'ओ', ''), 'о', 'و', 'θ', 'ို', 'ǒ', 'ǿ', 'º', 'ო', 'ओ', '',
'p' => array('п', 'π', 'ပ', 'პ', 'پ', ''), 'ö'],
'q' => array('', ''), 'p' => ['п', 'π', '', 'პ', 'پ', ''],
'r' => array('ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر', '', ''), 'q' => ['', ''],
's' => array('ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص', 'စ', 'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر', '', ''],
'ſ', '', ''), 's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص', '',
't' => array('ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط', '', '', 'ŧ', 'ſ', '', ''],
'', '', ''), 't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط', '', '', 'ŧ',
'u' => array('ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', '', '', '', '', '', ''],
'', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', '', 'u' => ['ú', 'ù', '', 'ũ', '', 'ư', '', '', '', '',
'', '', 'ǔ', 'ǖ', 'ǘ', 'ǚ', 'ǜ', '', '', '', '', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', '',
'ў'), 'ု', 'ူ', 'ǔ', 'ǖ', 'ǘ', 'ǚ', 'ǜ', 'უ', 'उ', '',
'v' => array('в', 'ვ', 'ϐ', ''), 'ў', 'ü'],
'w' => array('ŵ', 'ω', 'ώ', '', '', ''), 'v' => ['в', '', 'ϐ', ''],
'x' => array('χ', 'ξ', ''), 'w' => ['ŵ', 'ω', 'ώ', '', '', ''],
'y' => array('ý', 'ỳ', 'ỷ', 'ỹ', '', 'ÿ', 'ŷ', 'й', 'ы', 'υ', 'x' => ['χ', 'ξ', ''],
'ϋ', 'ύ', 'ΰ', 'ي', '', ''), 'y' => ['ý', 'ỳ', 'ỷ', 'ỹ', '', 'ÿ', 'ŷ', 'й', 'ы', 'υ',
'z' => array('ź', 'ž', 'ż', 'з', 'ζ', 'ز', '', '', ''), 'ϋ', 'ύ', 'ΰ', 'ي', '', ''],
'aa' => array('ع', '', 'آ'), 'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز', 'ဇ', 'ზ', ''],
'ae' => array('ä', 'æ', 'ǽ'), 'aa' => ['ع', '', 'آ'],
'ai' => array(''), 'ae' => ['æ', 'ǽ'],
'at' => array('@'), 'ai' => [''],
'ch' => array('ч', 'ჩ', 'ჭ', 'چ'), 'at' => ['@'],
'dj' => array('ђ', 'đ'), 'ch' => ['ч', '', '', 'چ'],
'dz' => array('џ', ''), 'dj' => ['ђ', 'đ'],
'ei' => array(''), 'dz' => ['џ', ''],
'gh' => array('غ', 'ღ'), 'ei' => [''],
'ii' => array(''), 'gh' => ['غ', ''],
'ij' => array('ij'), 'ii' => [''],
'kh' => array('х', 'خ', ''), 'ij' => ['ij'],
'lj' => array('љ'), 'kh' => ['х', 'خ', ''],
'nj' => array('њ'), 'lj' => ['љ'],
'oe' => array('ö', 'œ', 'ؤ'), 'nj' => ['њ'],
'oi' => array(''), 'oe' => ['œ', 'ؤ'],
'oii' => array(''), 'oi' => [''],
'ps' => array('ψ'), 'oii' => [''],
'sh' => array('ш', '', 'ش'), 'ps' => ['ψ'],
'shch' => array('щ'), 'sh' => ['ш', 'შ', 'ش'],
'ss' => array('ß'), 'shch' => ['щ'],
'sx' => array('ŝ'), 'ss' => ['ß'],
'th' => array('þ', 'ϑ', 'ث', 'ذ', 'ظ'), 'sx' => ['ŝ'],
'ts' => array('ц', '', ''), 'th' => ['þ', 'ϑ', 'ث', 'ذ', 'ظ'],
'ue' => array('ü'), 'ts' => ['ц', 'ც', ''],
'uu' => array('ऊ'), 'uu' => ['ऊ'],
'ya' => array('я'), 'ya' => ['я'],
'yu' => array('ю'), 'yu' => ['ю'],
'zh' => array('ж', 'ჟ', 'ژ'), 'zh' => ['ж', 'ჟ', 'ژ'],
'(c)' => array('©'), '(c)' => ['©'],
'A' => array('Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ', 'A' => ['Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ',
'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Å', 'Ā', 'Ą', 'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Å', 'Ā', 'Ą',
'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ',
'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ',
'Ὰ', 'Ά',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ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', 'Y' => ['Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ',
'Ы', 'Й', 'Υ', 'Ϋ', 'Ŷ', ''), 'Ы', 'Й', 'Υ', 'Ϋ', 'Ŷ', ''],
'Z' => array('Ź', 'Ž', 'Ż', 'З', 'Ζ', ''), 'Z' => ['Ź', 'Ž', 'Ż', 'З', 'Ζ', ''],
'AE' => array('Ä', 'Æ', 'Ǽ'), 'AE' => ['Æ', 'Ǽ'],
'CH' => array('Ч'), 'Ch' => ['Ч'],
'DJ' => array('Ђ'), 'Dj' => ['Ђ'],
'DZ' => array('Џ'), 'Dz' => ['Џ'],
'GX' => array('Ĝ'), 'Gx' => ['Ĝ'],
'HX' => array('Ĥ'), 'Hx' => ['Ĥ'],
'IJ' => array('IJ'), 'Ij' => ['IJ'],
'JX' => array('Ĵ'), 'Jx' => ['Ĵ'],
'KH' => array('Х'), 'Kh' => ['Х'],
'LJ' => array('Љ'), 'Lj' => ['Љ'],
'NJ' => array('Њ'), 'Nj' => ['Њ'],
'OE' => array('Ö', 'Œ'), 'Oe' => ['Œ'],
'PS' => array('Ψ'), 'Ps' => ['Ψ'],
'SH' => array('Ш'), 'Sh' => ['Ш'],
'SHCH' => array('Щ'), 'Shch' => ['Щ'],
'SS' => array('ẞ'), 'Ss' => ['ẞ'],
'TH' => array('Þ'), 'Th' => ['Þ'],
'TS' => array('Ц'), 'Ts' => ['Ц'],
'UE' => array('Ü'), 'Ya' => ['Я'],
'YA' => array('Я'), 'Yu' => ['Ю'],
'YU' => array('Ю'), 'Zh' => ['Ж'],
'ZH' => array('Ж'), ' ' => ["\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81",
' ' => array("\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81", "\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84",
"\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84", "\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87",
"\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87", "\xE2\x80\x88", "\xE2\x80\x89", "\xE2\x80\x8A",
"\xE2\x80\x88", "\xE2\x80\x89", "\xE2\x80\x8A", "\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80",
"\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80", "\xEF\xBE\xA0"],
"\xEF\xBE\xA0"), ];
); }
/**
* Returns language-specific replacements for the toAscii() method.
* For example, German will map 'ä' to 'ae', while other languages
* will simply return 'a'.
*
* param string $language Language of the source string
* @return array An array of replacements.
*/
protected static function langSpecificCharsArray($language = 'en')
{
$split = preg_split('/[-_]/', $language);
$language = strtolower($split[0]);
static $charsArray = [];
if (isset($charsArray[$language])) {
return $charsArray[$language];
}
$languageSpecific = [
'de' => [
['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü' ],
['ae', 'oe', 'ue', 'AE', 'OE', 'UE'],
]
];
if (isset($languageSpecific[$language])) {
$charsArray[$language] = $languageSpecific[$language];
} else {
$charsArray[$language] = [];
}
return $charsArray[$language];
} }
/** /**
@@ -1924,7 +1967,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
protected function supportsEncoding() protected function supportsEncoding()
{ {
$supported = array('UTF-8' => true, 'ASCII' => true); $supported = ['UTF-8' => true, 'ASCII' => true];
if (isset($supported[$this->encoding])) { if (isset($supported[$this->encoding])) {
return true; return true;

View File

@@ -15,25 +15,38 @@ class StaticStringyTestCase extends PHPUnit_Framework_TestCase
public function testEmptyArgsInvocation() public function testEmptyArgsInvocation()
{ {
$result = S::toLowerCase(); $result = S::toLowerCase();
$this->assertEquals('', (string) $result); $this->assertEquals('', $result);
} }
public function testInvocation() public function testInvocation()
{ {
$result = S::toLowerCase('FOOBAR'); $result = S::toLowerCase('FOOBAR');
$this->assertEquals('foobar', (string) $result); $this->assertEquals('foobar', $result);
$this->assertInternalType('string', $result);
} }
public function testPartialArgsInvocation() public function testPartialArgsInvocation()
{ {
$result = S::slice('foobar', 0, 3); $result = S::slice('foobar', 0, 3);
$this->assertEquals('foo', (string) $result); $this->assertEquals('foo', $result);
$this->assertInternalType('string', $result);
} }
public function testFullArgsInvocation() public function testFullArgsInvocation()
{ {
$result = S::slice('fòôbàř', 0, 3, 'UTF-8'); $result = S::slice('fòôbàř', 0, 3, 'UTF-8');
$this->assertEquals('fòô', (string) $result); $this->assertEquals('fòô', $result);
$this->assertInternalType('string', $result);
}
public function testArrayReturnValue()
{
$result = S::lines("a\nb");
$this->assertEquals(['a', 'b'], $result);
$this->assertInternalType('array', $result);
foreach ($result as $val) {
$this->assertInternalType('string', $val);
}
} }
/** /**

File diff suppressed because it is too large Load Diff