Skip to content

Commit 31921d5

Browse files
committed
Squash for 2.0.0
1 parent 9f06789 commit 31921d5

7 files changed

Lines changed: 100 additions & 99 deletions

File tree

String.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,25 @@
1313
/**
1414
* The String class.
1515
*
16-
* @since {DEPLOY_VERSION}
16+
* @since 2.0
1717
*/
1818
abstract class String
1919
{
20+
const INCREMENT_STYLE_DASH = 'dash';
21+
const INCREMENT_STYLE_DEFAULT = 'default';
22+
2023
/**
2124
* Increment styles.
2225
*
2326
* @var array
24-
* @since {DEPLOY_VERSION}
27+
* @since 2.0
2528
*/
2629
protected static $incrementStyles = array(
27-
'dash' => array(
30+
self::INCREMENT_STYLE_DASH => array(
2831
'#-(\d+)$#',
2932
'-%d'
3033
),
31-
'default' => array(
34+
self::INCREMENT_STYLE_DEFAULT => array(
3235
array('#\((\d+)\)$#', '#\(\d+\)$#'),
3336
array(' (%d)', '(%d)'),
3437
),
@@ -69,16 +72,13 @@ public static function isZero($string)
6972
* Quote a string.
7073
*
7174
* @param string $string The string to quote.
72-
* @param string $quote The quote symbol.
75+
* @param array $quote The quote symbol.
7376
*
7477
* @return string Quoted string.
7578
*/
76-
public static function quote($string, $quote = "''")
79+
public static function quote($string, $quote = array('{@', '@}'))
7780
{
78-
if (!strlen($quote))
79-
{
80-
return $string;
81-
}
81+
$quote = (array) $quote;
8282

8383
if (empty($quote[1]))
8484
{
@@ -97,7 +97,7 @@ public static function quote($string, $quote = "''")
9797
*/
9898
public static function backquote($string)
9999
{
100-
return static::quote($string, '``');
100+
return static::quote($string, '`');
101101
}
102102

103103
/**
@@ -154,9 +154,9 @@ function($match) use ($data)
154154
*
155155
* @return string The incremented string.
156156
*
157-
* @since {DEPLOY_VERSION}
157+
* @since 2.0
158158
*/
159-
public static function increment($string, $style = 'default', $n = 0)
159+
public static function increment($string, $style = self::INCREMENT_STYLE_DEFAULT, $n = 0)
160160
{
161161
$styleSpec = isset(self::$incrementStyles[$style]) ? self::$incrementStyles[$style] : self::$incrementStyles['default'];
162162

StringInflector.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
*
1414
* The Inflector transforms words. This class is based on Joomla String package
1515
*
16-
* @since {DEPLOY_VERSION}
16+
* @since 2.0
1717
*/
1818
class StringInflector
1919
{
2020
/**
2121
* The singleton instance.
2222
*
2323
* @var StringInflector
24-
* @since {DEPLOY_VERSION}
24+
* @since 2.0
2525
*/
2626
private static $instance;
2727

2828
/**
2929
* The inflector rules for singularisation, pluralisation and countability.
3030
*
3131
* @var array
32-
* @since {DEPLOY_VERSION}
32+
* @since 2.0
3333
*/
3434
private $rules = array(
3535
'singular' => array(
@@ -76,14 +76,14 @@ class StringInflector
7676
* The array is in the form [singular => plural]
7777
*
7878
* @var array
79-
* @since {DEPLOY_VERSION}
79+
* @since 2.0
8080
*/
8181
private $cache = array();
8282

8383
/**
8484
* Protected constructor.
8585
*
86-
* @since {DEPLOY_VERSION}
86+
* @since 2.0
8787
*/
8888
protected function __construct()
8989
{
@@ -122,7 +122,7 @@ protected function __construct()
122122
*
123123
* @return void
124124
*
125-
* @since {DEPLOY_VERSION}
125+
* @since 2.0
126126
* @throws \InvalidArgumentException
127127
*/
128128
private function addRule($data, $ruleType)
@@ -151,7 +151,7 @@ private function addRule($data, $ruleType)
151151
*
152152
* @return mixed The cached inflection or false if none found.
153153
*
154-
* @since {DEPLOY_VERSION}
154+
* @since 2.0
155155
*/
156156
private function getCachedPlural($singular)
157157
{
@@ -173,7 +173,7 @@ private function getCachedPlural($singular)
173173
*
174174
* @return mixed The cached inflection or false if none found.
175175
*
176-
* @since {DEPLOY_VERSION}
176+
* @since 2.0
177177
*/
178178
private function getCachedSingular($plural)
179179
{
@@ -193,7 +193,7 @@ private function getCachedSingular($plural)
193193
*
194194
* @return mixed An inflected string, or false if no rule could be applied.
195195
*
196-
* @since {DEPLOY_VERSION}
196+
* @since 2.0
197197
*/
198198
private function matchRegexRule($word, $ruleType)
199199
{
@@ -220,7 +220,7 @@ private function matchRegexRule($word, $ruleType)
220220
*
221221
* @return void
222222
*
223-
* @since {DEPLOY_VERSION}
223+
* @since 2.0
224224
*/
225225
private function setCache($singular, $plural = null)
226226
{
@@ -245,7 +245,7 @@ private function setCache($singular, $plural = null)
245245
*
246246
* @return static Returns this object to support chaining.
247247
*
248-
* @since {DEPLOY_VERSION}
248+
* @since 2.0
249249
*/
250250
public function addCountableRule($data)
251251
{
@@ -262,7 +262,7 @@ public function addCountableRule($data)
262262
*
263263
* @return static Returns this object to support chaining.
264264
*
265-
* @since {DEPLOY_VERSION}
265+
* @since 2.0
266266
*/
267267
public function addWord($singular, $plural =null)
268268
{
@@ -278,7 +278,7 @@ public function addWord($singular, $plural =null)
278278
*
279279
* @return static Returns this object to support chaining.
280280
*
281-
* @since {DEPLOY_VERSION}
281+
* @since 2.0
282282
*/
283283
public function addPluraliseRule($data)
284284
{
@@ -294,7 +294,7 @@ public function addPluraliseRule($data)
294294
*
295295
* @return static Returns this object to support chaining.
296296
*
297-
* @since {DEPLOY_VERSION}
297+
* @since 2.0
298298
*/
299299
public function addSingulariseRule($data)
300300
{
@@ -311,7 +311,7 @@ public function addSingulariseRule($data)
311311
*
312312
* @return static
313313
*
314-
* @since {DEPLOY_VERSION}
314+
* @since 2.0
315315
*/
316316
public static function getInstance($new = false)
317317
{
@@ -334,7 +334,7 @@ public static function getInstance($new = false)
334334
*
335335
* @return boolean True if word is countable, false otherwise.
336336
*
337-
* @since {DEPLOY_VERSION}
337+
* @since 2.0
338338
*/
339339
public function isCountable($word)
340340
{
@@ -348,7 +348,7 @@ public function isCountable($word)
348348
*
349349
* @return boolean True if word is plural, false if not.
350350
*
351-
* @since {DEPLOY_VERSION}
351+
* @since 2.0
352352
*/
353353
public function isPlural($word)
354354
{
@@ -371,7 +371,7 @@ public function isPlural($word)
371371
*
372372
* @return boolean True if word is singular, false if not.
373373
*
374-
* @since {DEPLOY_VERSION}
374+
* @since 2.0
375375
*/
376376
public function isSingular($word)
377377
{
@@ -394,7 +394,7 @@ public function isSingular($word)
394394
*
395395
* @return mixed An inflected string, or false if no rule could be applied.
396396
*
397-
* @since {DEPLOY_VERSION}
397+
* @since 2.0
398398
*/
399399
public function toPlural($word)
400400
{
@@ -432,7 +432,7 @@ public function toPlural($word)
432432
*
433433
* @return mixed An inflected string, or false if no rule could be applied.
434434
*
435-
* @since {DEPLOY_VERSION}
435+
* @since 2.0
436436
*/
437437
public function toSingular($word)
438438
{

StringNormalise.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* This class is based on Joomla String package
1515
*
16-
* @since {DEPLOY_VERSION}
16+
* @since 2.0
1717
*/
1818
abstract class StringNormalise
1919
{
@@ -37,7 +37,7 @@ abstract class StringNormalise
3737
*
3838
* @return string The space separated string.
3939
*
40-
* @since {DEPLOY_VERSION}
40+
* @since 2.0
4141
*/
4242
public static function fromCamelCase($input, $grouped = false)
4343
{
@@ -53,7 +53,7 @@ public static function fromCamelCase($input, $grouped = false)
5353
*
5454
* @return string The camel case string.
5555
*
56-
* @since {DEPLOY_VERSION}
56+
* @since 2.0
5757
*/
5858
public static function toCamelCase($input)
5959
{
@@ -72,7 +72,7 @@ public static function toCamelCase($input)
7272
*
7373
* @return string The dash separated string.
7474
*
75-
* @since {DEPLOY_VERSION}
75+
* @since 2.0
7676
*/
7777
public static function toDashSeparated($input)
7878
{
@@ -89,7 +89,7 @@ public static function toDashSeparated($input)
8989
*
9090
* @return string The space separated string.
9191
*
92-
* @since {DEPLOY_VERSION}
92+
* @since 2.0
9393
*/
9494
public static function toSpaceSeparated($input)
9595
{
@@ -106,7 +106,7 @@ public static function toSpaceSeparated($input)
106106
*
107107
* @return string The underscore separated string.
108108
*
109-
* @since {DEPLOY_VERSION}
109+
* @since 2.0
110110
*/
111111
public static function toUnderscoreSeparated($input)
112112
{
@@ -123,7 +123,7 @@ public static function toUnderscoreSeparated($input)
123123
*
124124
* @return string The variable string.
125125
*
126-
* @since {DEPLOY_VERSION}
126+
* @since 2.0
127127
*/
128128
public static function toVariable($input)
129129
{
@@ -151,7 +151,7 @@ public static function toVariable($input)
151151
*
152152
* @return string The key string.
153153
*
154-
* @since {DEPLOY_VERSION}
154+
* @since 2.0
155155
*/
156156
public static function toKey($input)
157157
{
@@ -169,7 +169,7 @@ public static function toKey($input)
169169
*
170170
* @return string Normalised class name.
171171
*
172-
* @since {DEPLOY_VERSION}
172+
* @since 2.0
173173
*/
174174
public static function toClassNamespace($class)
175175
{

Test/StringTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Test class of String
1515
*
16-
* @since {DEPLOY_VERSION}
16+
* @since 2.0
1717
*/
1818
class StringTest extends \PHPUnit_Framework_TestCase
1919
{
@@ -61,8 +61,8 @@ public function testIsZero()
6161
public function testQuote()
6262
{
6363
$this->assertEquals('"foo"', String::quote('foo', '"'));
64-
$this->assertEquals('"foo"', String::quote('foo', '""'));
65-
$this->assertEquals('[foo]', String::quote('foo', '[]'));
64+
$this->assertEquals('"foo"', String::quote('foo', array('"', '"')));
65+
$this->assertEquals('[foo]', String::quote('foo', array('[', ']')));
6666
}
6767

6868
/**

Test/Utf8StringTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* Test class of String
1616
*
17-
* @since {DEPLOY_VERSION}
17+
* @since 2.0
1818
*/
1919
class Utf8StringTest extends \PHPUnit_Framework_TestCase
2020
{

0 commit comments

Comments
 (0)