mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-09-01 09:03:03 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
63ad4d238f | ||
|
ece219b609 | ||
|
e81dbaa6d9 | ||
|
2b2c03bd1f | ||
|
7600549abc | ||
|
8fe30d18b7 | ||
|
ae7527ad4a | ||
|
f74f535b78 | ||
|
5c5087db13 |
@@ -1,5 +1,10 @@
|
|||||||
language: php
|
language: php
|
||||||
php:
|
php:
|
||||||
|
- 5.6
|
||||||
- 5.5
|
- 5.5
|
||||||
- 5.4
|
- 5.4
|
||||||
- 5.3
|
- 5.3
|
||||||
|
- hhvm
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
|
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,3 +1,13 @@
|
|||||||
|
### 1.5.2 (2014-07-09)
|
||||||
|
|
||||||
|
* Announced support for HHVM
|
||||||
|
|
||||||
|
### 1.5.1 (2014-04-19)
|
||||||
|
|
||||||
|
* Fixed toAscii() failing to remove remaining non-ascii characters
|
||||||
|
* Updated slugify() to treat dash and underscore as delimiters by default
|
||||||
|
* Updated slugify() to remove leading and trailing delimiter, if present
|
||||||
|
|
||||||
### 1.5.0 (2014-03-19)
|
### 1.5.0 (2014-03-19)
|
||||||
|
|
||||||
* Made both str and encoding protected, giving property access to subclasses
|
* Made both str and encoding protected, giving property access to subclasses
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
A PHP library with a variety of string manipulation functions with multibyte
|
A PHP library with a variety of string manipulation functions with multibyte
|
||||||
support. Offers both OO method chaining and a procedural-style static wrapper.
|
support. Offers both OO method chaining and a procedural-style static wrapper.
|
||||||
Compatible with PHP 5.3+. Inspired by underscore.string.js.
|
Tested and compatible with PHP 5.3+ and HHVM. Inspired by underscore.string.js.
|
||||||
|
|
||||||
[](https://travis-ci.org/danielstjules/Stringy)
|
[](https://travis-ci.org/danielstjules/Stringy)
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ If you're using Composer to manage dependencies, you can include the following
|
|||||||
in your composer.json file:
|
in your composer.json file:
|
||||||
|
|
||||||
"require": {
|
"require": {
|
||||||
"danielstjules/stringy": ">=1.5.0"
|
"danielstjules/stringy": ">=1.5.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
Then, after running `composer update` or `php composer.phar update`, you can
|
Then, after running `composer update` or `php composer.phar update`, you can
|
||||||
|
@@ -488,6 +488,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
$str = str_replace($value, $key, $str);
|
$str = str_replace($value, $key, $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$str = preg_replace('/[^\x20-\x7E]/u', '', $str);
|
||||||
|
|
||||||
return self::create($str, $this->encoding);
|
return self::create($str, $this->encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -714,13 +716,12 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
{
|
{
|
||||||
$stringy = self::create($this->str, $this->encoding);
|
$stringy = self::create($this->str, $this->encoding);
|
||||||
|
|
||||||
$stringy->str = preg_replace("/[^a-zA-Z\d $replacement]/u", '',
|
$quotedReplacement = preg_quote($replacement);
|
||||||
$stringy->toAscii());
|
$pattern = "/[^a-zA-Z\d\s-_$quotedReplacement]/u";
|
||||||
$stringy->str = $stringy->collapseWhitespace()->str;
|
$stringy->str = preg_replace($pattern, '', $stringy->toAscii());
|
||||||
$stringy->str = str_replace(' ', $replacement, strtolower($stringy));
|
|
||||||
$stringy->str = preg_replace("/[$replacement]+/u", $replacement, $stringy);
|
|
||||||
|
|
||||||
return $stringy;
|
return $stringy->toLowerCase()->applyDelimeter($replacement)
|
||||||
|
->removeLeft($replacement)->removeRight($replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -174,10 +174,11 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
|
|||||||
return array(
|
return array(
|
||||||
array('foo bar', 'fòô bàř'),
|
array('foo bar', 'fòô bàř'),
|
||||||
array(' TEST ', ' ŤÉŚŢ '),
|
array(' TEST ', ' ŤÉŚŢ '),
|
||||||
array('φ = z = 3', 'φ = ź = 3'),
|
array(' = z = 3', 'φ = ź = 3'),
|
||||||
array('perevirka', 'перевірка'),
|
array('perevirka', 'перевірка'),
|
||||||
array('lysaya gora', 'лысая гора'),
|
array('lysaya gora', 'лысая гора'),
|
||||||
array('shchuka', 'щука')
|
array('shchuka', 'щука'),
|
||||||
|
array('', '漢字')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,11 +342,12 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
|
|||||||
array('numbers-1234', 'numbers 1234'),
|
array('numbers-1234', 'numbers 1234'),
|
||||||
array('perevirka-ryadka', 'перевірка рядка'),
|
array('perevirka-ryadka', 'перевірка рядка'),
|
||||||
array('bukvar-s-bukvoy-y', 'букварь с буквой ы'),
|
array('bukvar-s-bukvoy-y', 'букварь с буквой ы'),
|
||||||
// Conflicts between Russian or Bulgarian
|
|
||||||
//array('barzi-i-yarostni', 'бързи и яростни'),
|
|
||||||
array('podekhal-k-podezdu-moego-doma', 'подъехал к подъезду моего дома'),
|
array('podekhal-k-podezdu-moego-doma', 'подъехал к подъезду моего дома'),
|
||||||
array('foo:bar:baz', 'Foo bar baz', ':'),
|
array('foo:bar:baz', 'Foo bar baz', ':'),
|
||||||
array('a_string_with_underscores', 'A_string with_underscores', '_')
|
array('a_string_with_underscores', 'A_string with_underscores', '_'),
|
||||||
|
array('a_string_with_dashes', 'A string-with-dashes', '_'),
|
||||||
|
array('a\string\with\dashes', 'A string-with-dashes', '\\'),
|
||||||
|
array('an_odd_string', '-- An odd__ string-_', '_')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user